⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch25_08.htm

📁 编程珍珠,里面很多好用的代码,大家可以参考学习呵呵,
💻 HTM
字号:
<html><head><title>Dates and Times (Programming Perl)</title><!-- STYLESHEET --><link rel="stylesheet" type="text/css" href="../style/style1.css"><!-- METADATA --><!--Dublin Core Metadata--><meta name="DC.Creator" content=""><meta name="DC.Date" content=""><meta name="DC.Format" content="text/xml" scheme="MIME"><meta name="DC.Generator" content="XSLT stylesheet, xt by James Clark"><meta name="DC.Identifier" content=""><meta name="DC.Language" content="en-US"><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="Dates and Times"><meta name="DC.Type" content="Text.Monograph"></head><body><!-- START OF BODY --><!-- TOP BANNER --><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home"><map name="banner-map"><AREA SHAPE="RECT" COORDS="0,0,466,71" HREF="index.htm" ALT="Programming Perl"><AREA SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"></map><!-- TOP NAV BAR --><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch25_07.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="ch25_01.htm">Chapter 25: Portable Perl</a></td><td align="right" valign="top" width="172"><a href="ch25_09.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h2 class="sect1">25.8. Dates and Times</h2><p><a name="INDEX-4365"></a><a name="INDEX-4366"></a>Where possible, use the ISO-8601 standard ("<em class="replaceable">YYYY</em>-<em class="replaceable">MM</em>-<em class="replaceable">DD</em>") to representdates.  Strings like "<tt class="literal">1987-12-18</tt>" can be easily converted into asystem-specific value with a module like <tt class="literal">Date::Parse</tt>.  A list oftime and date values (such as that returned by the built-in <tt class="literal">localtime</tt>function) can be converted to a system-specific representation using<tt class="literal">Time::Local</tt>.</p><p>The built-in <tt class="literal">time</tt> function will always return the number of secondssince the beginning of the "epoch", but operating systems differ intheir opinions of when that was.  On many systems, the epoch began onJanuary 1, 1970, at 00:00:00 UTC, but it began 66 years earlier on Macs,and on VMS it began on November 17, 1858, at 00:00:00.  So for portabletimes you may want to calculate an offset for the epoch:<blockquote><pre class="programlisting">require Time::Local;$offset = Time::Local::timegm(0, 0, 0, 1, 0, 70);</pre></blockquote>The value for <tt class="literal">$offset</tt> in Unix and Windows willalways be <tt class="literal">0</tt>, but on Macs and VMS it may be somelarge number.  <tt class="literal">$offset</tt> can then be added to a Unixtime value to get what should be the same value on any system.</p><p>A system's representation of the time of day and the calendar date canbe controlled in widely different ways.  Don't assume the time zone isstored in <tt class="literal">$ENV{TZ}</tt>.  Even if it is, don't assumethat you can control the time zone through that variable.</p><!-- BOTTOM NAV BAR --><hr width="515" align="left"><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch25_07.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="index.htm"><img src="../gifs/txthome.gif" alt="Home" border="0"></a></td><td align="right" valign="top" width="172"><a href="ch25_09.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr><tr><td align="left" valign="top" width="172">25.7. Standard Modules</td><td align="center" valign="top" width="171"><a href="index/index.htm"><img src="../gifs/index.gif" alt="Book Index" border="0"></a></td><td align="right" valign="top" width="172">25.9. Internationalization</td></tr></table></div><hr width="515" align="left"><!-- LIBRARY NAV BAR --><img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2001</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"> <area shape="rect" coords="2,-1,79,99" href="../index.htm"><area shape="rect" coords="84,1,157,108" href="../perlnut/index.htm"><area shape="rect" coords="162,2,248,125" href="../prog/index.htm"><area shape="rect" coords="253,2,326,130" href="../advprog/index.htm"><area shape="rect" coords="332,1,407,112" href="../cookbook/index.htm"><area shape="rect" coords="414,2,523,103" href="../sysadmin/index.htm"></map><!-- END OF BODY --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -