<ppdoc>
<copyright>
Copyright (c) 2001 by Addison Wesley Longman, Inc. This material may
be distributed only subject to the terms and conditions set forth in
the Open Publication License, v1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
<p/>
Distribution of substantively modified versions of this document is
prohibited without the explicit permission of the copyright holder.
<p/>
Distribution of the work or derivative of the work in any standard
(paper) book form is prohibited unless prior permission is obtained
from the copyright holder.
</copyright>
<class name="Time" super="Object" type="class" ref="xref-000001">
    <classname>Time</classname> is an abstraction of dates and times.  Time is stored
  internally as the number of seconds and microseconds since the
  <em>epoch</em>, January 1, 1970 00:00<nbsp/>UTC. Also see the library
  modules <modulename>Date</modulename> and <modulename>ParseDate</modulename>, documented beginning on pages
  439 and 453, respectively.          
  The <classname>Time</classname> class treats GMT (Greenwich Mean Time) and UTC
  (Coordinated Universal Time)<footnote>Yes, UTC really does stand for
    Coordinated Universal Time. There was a committee involved.</footnote>
  as equivalent. GMT is the older way of
  referring to these baseline times but persists in the names of
  calls on Posix systems.
<p/>
  All times are stored with some number of microseconds.
  Be aware of this fact when
  comparing times with each other---times that are apparently equal
  when displayed may be different when compared.
  <mixins>
    <mixin name="Comparable">
   &lt;, &lt;=, ==, &gt;=, &gt;, between?</mixin>
  </mixins>
<p/>
  <methods type="class">
        <method name="at" ref="at">
      <callseq>
                Time.at( <obj>aTime</obj> ) <returns><obj>aTime</obj></returns> <br/>Time.at( <obj>seconds</obj> <opt>, <obj>microseconds</obj></opt> ) 
          <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
      Creates a new time object with the value given by <obj>aTime</obj>,
      or the given number of <obj>seconds</obj> (and optional <obj>microseconds</obj>)
      from epoch.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.at(0)
        Time.at(946702800)
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.at(0)</tt></td>
  <td>&#187;</td>
  <td><tt>Wed<nbsp/>Dec<nbsp/>31<nbsp/>18:00:00<nbsp/>CST<nbsp/>1969</tt></td>
</tr>
<tr>
  <td><tt>Time.at(946702800)</tt></td>
  <td>&#187;</td>
  <td><tt>Fri<nbsp/>Dec<nbsp/>31<nbsp/>23:00:00<nbsp/>CST<nbsp/>1999</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="gm" ref="gm">
      <callseq>
                  Time.gm( <obj>year <opt>, month, day, hour, min, sec, usec</opt></obj> )
        <returns><obj>aTime</obj></returns> <br/>Time.gm( <obj>sec, min, hour, day, month, year, wday, yday,
            isdst, tz</obj> )
        <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
    Creates a time based on given values, interpreted as UTC (GMT).  The
    year must be specified. Other values default to the minimum value
    for that field (and may be <tt>nil</tt> or omitted).  Months may be
    specified by numbers from 1 to 12, or by the three-letter English month
    names. Hours are specified on a 24-hour clock (0..23). Raises an
    <exception>ArgumentError</exception> if any values are out of range.  Will also
    accept ten arguments in the order output by <cim><file>time</file><front>Time</front><back>to_a</back><mref>to_a</mref></cim>.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.gm(2000,"jan",1,20,15,1)
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.gm(2000,"jan",1,20,15,1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>20:15:01<nbsp/>UTC<nbsp/>2000</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="local" ref="local">
      <callseq>
                  Time.local( <obj>year <opt>, month, day, hour, min, sec, usec</opt></obj> )
          <returns><obj>aTime</obj></returns> <br/>Time.local( <obj>sec, min, hour, day, month, year, wday, yday, isdst, tz</obj> )
          <returns><obj>aTime</obj></returns>
<p/>
      </callseq>
      <desc>
<p/>
      Same as <ccm><file>time</file><front>Time</front><back>gm</back><mref>gm</mref></ccm>, but interprets the values in the local
      time zone.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.local(2000,"jan",1,20,15,1)
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.local(2000,"jan",1,20,15,1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>20:15:01<nbsp/>CST<nbsp/>2000</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="mktime" ref="mktime">
      <callseq>
        Time.mktime(
        <obj>year, month, day, hour, min, sec, usec</obj> )
        <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <ccm><file>time</file><front>Time</front><back>local</back><mref>local</mref></ccm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="new" ref="new">
      <callseq>
        Time.new
        <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a <classname>Time</classname> object initialized to the current system
      time. <b>Note:</b> The object created will be created using
      the resolution available on your system clock, and so may
      include fractional seconds.
<p/>
<codefragment>
<fullcode><![CDATA[        a = Time.new
        b = Time.new
!- raise "time problem" unless a.to_i == b.to_i
!- raise "time problem" if a == b
        a == b
        "%.6f" % a.to_f
        "%.6f" % b.to_f
]]></fullcode><rubycode>
<tr>
  <td><tt>a<nbsp/>=<nbsp/>Time.new</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>b<nbsp/>=<nbsp/>Time.new</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>a<nbsp/>==<nbsp/>b</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>"%.6f"<nbsp/>%<nbsp/>a.to_f</tt></td>
  <td>&#187;</td>
  <td><tt>"1023599960.526217"</tt></td>
</tr>
<tr>
  <td><tt>"%.6f"<nbsp/>%<nbsp/>b.to_f</tt></td>
  <td>&#187;</td>
  <td><tt>"1023599960.526838"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="now" ref="now">
      <callseq>
        Time.now <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <ccm><file>time</file><front>Time</front><back>new</back><mref>new</mref></ccm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="times" ref="times">
      <callseq>
        Time.times
        <returns><obj>aStructTms</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a <tt>Tms</tt> structure (see <classname>Struct::Tms</classname>
      on page 383) that contains
      user and system CPU times for this process.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.times
        [ t.utime, t.stime ]
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.times</tt></td>
</tr>
<tr>
  <td><tt>[<nbsp/>t.utime,<nbsp/>t.stime<nbsp/>]</tt></td>
  <td>&#187;</td>
  <td><tt>[0.04,<nbsp/>0.0]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="utc" ref="utc">
      <callseq>
                  Time.utc( <obj>year <opt>, month, day, hour, min, sec, usec</opt></obj> )
        <returns><obj>aTime</obj></returns> <br/>Time.utc( <obj>sec, min, hour, day, month, year, wday, yday,
            isdst, tz</obj> )
        <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
    Synonym for <ccm><file>time</file><front>Time</front><back>gm</back><mref>gm</mref></ccm>.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.utc(2000,"jan",1,20,15,1)
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.utc(2000,"jan",1,20,15,1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>20:15:01<nbsp/>UTC<nbsp/>2000</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
  <methods type="instance">
<p/>
        <method name="+" ref="_pl">
      <callseq>
        <obj>time</obj> + <obj>aNumeric</obj> 
        <returns><obj>aTime</obj></returns>
      </callseq>
      <desc>
<p/>
      Addition---Adds some number of seconds (possibly fractional) to <obj>time</obj>
      and returns that value as a new time.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t + (60 * 60 * 24)
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>+<nbsp/>(60<nbsp/>*<nbsp/>60<nbsp/>*<nbsp/>24)</tt></td>
  <td>&#187;</td>
  <td><tt>Mon<nbsp/>Jun<nbsp/>10<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="--" ref="_mi_mi">
      <callseq>
                  <obj>time</obj> <tt>-</tt> <obj>aTime</obj> <returns><obj>aFloat</obj></returns> <br/><obj>time</obj> <tt>-</tt> <obj>aNumeric</obj> <returns><obj>aTime</obj></returns>          
      </callseq>
      <desc>
<p/>
      Difference---Returns a new time that represents the difference between two
      times, or subtracts the given number of seconds in
      <obj>aNumeric</obj> from <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t2 = t + 2592000
        t2 - t
        t2 - 2592000
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>=<nbsp/>t<nbsp/>+<nbsp/>2592000</tt></td>
  <td>&#187;</td>
  <td><tt>Tue<nbsp/>Jul<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>-<nbsp/>t</tt></td>
  <td>&#187;</td>
  <td><tt>2592000.0</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>-<nbsp/>2592000</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="&lt;=&gt;" ref="_lt_eq_lt">
      <callseq>
                  <obj>time</obj> &lt;=&gt; <obj>anOtherTime</obj>
        <returns>-1, 0, +1</returns> <br/><obj>time</obj> &lt;=&gt; <obj>aNumeric</obj>
        <returns>-1, 0, +1</returns>
      </callseq>
      <desc>
<p/>
      Comparison---Compares <obj>time</obj> with <obj>anOtherTime</obj> or with
      <obj>aNumeric</obj>, which is the number of seconds (possibly
      fractional) since epoch.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t2 = t + 2592000
        t <=> t2
        t2 <=> t
        t <=> t
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>=<nbsp/>t<nbsp/>+<nbsp/>2592000</tt></td>
  <td>&#187;</td>
  <td><tt>Tue<nbsp/>Jul<nbsp/>09<nbsp/>00:19:20<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>&lt;=&gt;<nbsp/>t2</tt></td>
  <td>&#187;</td>
  <td><tt>-1</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>&lt;=&gt;<nbsp/>t</tt></td>
  <td>&#187;</td>
  <td><tt>1</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>&lt;=&gt;<nbsp/>t</tt></td>
  <td>&#187;</td>
  <td><tt>0</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="asctime" ref="asctime">
      <callseq>
        <obj>time</obj>.asctime
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a canonical string representation of <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.now.asctime
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.now.asctime</tt></td>
  <td>&#187;</td>
  <td><tt>"Sun<nbsp/>Jun<nbsp/><nbsp/>9<nbsp/>00:19:21<nbsp/>2002"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="ctime" ref="ctime">
      <callseq>
        <obj>time</obj>.ctime
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>asctime</back><mref>asctime</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="day" ref="day">
      <callseq>
        <obj>time</obj>.day
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the day of the month (1..n) for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.day
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.day</tt></td>
  <td>&#187;</td>
  <td><tt>9</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="gmt?" ref="gmt_qm">
      <callseq>
        <obj>time</obj>.gmt?
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>time</obj> represents a time in UTC (GMT).
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.gmt?
        t = Time.gm(2000,"jan",1,20,15,1)
        t.gmt?
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.gm(2000,"jan",1,20,15,1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>20:15:01<nbsp/>UTC<nbsp/>2000</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="gmtime" ref="gmtime">
      <callseq>
        <obj>time</obj>.gmtime
        <returns><obj>time</obj></returns>
      </callseq>
      <desc>
<p/>
      Converts <obj>time</obj> to UTC (GMT), modifying the receiver.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.gmt?
        t.gmtime
        t.gmt?
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>t.gmtime</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>05:19:21<nbsp/>UTC<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="hour" ref="hour">
      <callseq>
        <obj>time</obj>.hour
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the hour of the day (0..23) for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.hour
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.hour</tt></td>
  <td>&#187;</td>
  <td><tt>0</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="isdst" ref="isdst">
      <callseq>
        <obj>time</obj>.isdst
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>time</obj> occurs during Daylight Saving 
      Time in its time zone.
<p/>
<codefragment>
<fullcode><![CDATA[        t  = Time.local(2000, 7, 1)
        t.isdst
        t2 = Time.local(2000, 1, 1)
        t2.isdst
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/><nbsp/>=<nbsp/>Time.local(2000,<nbsp/>7,<nbsp/>1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jul<nbsp/>01<nbsp/>00:00:00<nbsp/>CDT<nbsp/>2000</tt></td>
</tr>
<tr>
  <td><tt>t.isdst</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>t2<nbsp/>=<nbsp/>Time.local(2000,<nbsp/>1,<nbsp/>1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>00:00:00<nbsp/>CST<nbsp/>2000</tt></td>
</tr>
<tr>
  <td><tt>t2.isdst</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="localtime" ref="localtime">
      <callseq>
        <obj>time</obj>.localtime
        <returns><obj>time</obj></returns>
      </callseq>
      <desc>
<p/>
      Converts <obj>time</obj> to local time (using the local time zone in
      effect for this process) modifying the receiver.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.gm(2000, "jan", 1, 20, 15, 1)
        t.gmt?
        t.localtime
        t.gmt?
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.gm(2000,<nbsp/>"jan",<nbsp/>1,<nbsp/>20,<nbsp/>15,<nbsp/>1)</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
<tr>
  <td><tt>t.localtime</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>14:15:01<nbsp/>CST<nbsp/>2000</tt></td>
</tr>
<tr>
  <td><tt>t.gmt?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="mday" ref="mday">
      <callseq>
        <obj>time</obj>.mday
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>day</back><mref>day</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="min" ref="min">
      <callseq>
        <obj>time</obj>.min
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the minute of the hour (0..59) for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.min
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.min</tt></td>
  <td>&#187;</td>
  <td><tt>19</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="mon" ref="mon">
      <callseq>
        <obj>time</obj>.mon
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the month of the year (1..12) for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.mon
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.mon</tt></td>
  <td>&#187;</td>
  <td><tt>6</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="month" ref="month">
      <callseq>
        <obj>time</obj>.month
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>mon</back><mref>mon</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="sec" ref="sec">
      <callseq>
        <obj>time</obj>.sec
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
         Returns the second of the minute
      (0..60)<footnote>Yes, seconds really can range from zero to
        60. This allows the system to inject leap seconds        
        every now
        and then to correct for the fact that years are not really a
        convenient number of hours long.</footnote> for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.sec
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.sec</tt></td>
  <td>&#187;</td>
  <td><tt>21</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="strftime" ref="strftime">
      <callseq>
        <obj>time</obj>.strftime( <obj>aString</obj> )
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Formats <obj>time</obj> according to the directives in the given format
      string.  See Table 22.9 on page 397 for the available values.
      Any text not listed as a directive will be passed through to the
      output string.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.strftime("Printed on %m/%d/%Y")
        t.strftime("at %I:%M%p")
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
</tr>
<tr>
  <td><tt>t.strftime("Printed<nbsp/>on<nbsp/>%m/%d/%Y")</tt></td>
  <td>&#187;</td>
  <td><tt>"Printed<nbsp/>on<nbsp/>06/09/2002"</tt></td>
</tr>
<tr>
  <td><tt>t.strftime("at<nbsp/>%I:%M%p")</tt></td>
  <td>&#187;</td>
  <td><tt>"at<nbsp/>12:19AM"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
    <figure type="table">
      <caption><cim><file>time</file><front>Time</front><back>strftime</back><mref>strftime</mref></cim> directives</caption>
      <table>
<th>
  <td><b>Format</b></td>
  <td><b>Meaning</b></td>
</th>
<tr>
  <td>%a</td>
  <td>The abbreviated weekday name (``Sun'')</td>
</tr>
<tr>
  <td>%A</td>
  <td>The  full  weekday  name (``Sunday'')</td>
</tr>
<tr>
  <td>%b</td>
  <td>The abbreviated month name (``Jan'')</td>
</tr>
<tr>
  <td>%B</td>
  <td>The  full  month  name (``January'')</td>
</tr>
<tr>
  <td>%c</td>
  <td>The preferred local date and time representation</td>
</tr>
<tr>
  <td>%d</td>
  <td>Day of the month (01..31)</td>
</tr>
<tr>
  <td>%H</td>
  <td>Hour of the day, 24-hour clock (00..23)</td>
</tr>
<tr>
  <td>%I</td>
  <td>Hour of the day, 12-hour clock (01..12)</td>
</tr>
<tr>
  <td>%j</td>
  <td>Day of the year (001..366)</td>
</tr>
<tr>
  <td>%m</td>
  <td>Month of the year (01..12)</td>
</tr>
<tr>
  <td>%M</td>
  <td>Minute of the hour (00..59)</td>
</tr>
<tr>
  <td>%p</td>
  <td>Meridian indicator (``AM''  or  ``PM'')</td>
</tr>
<tr>
  <td>%S</td>
  <td>Second of the minute (00..60)</td>
</tr>
<tr>
  <td>%U</td>
  <td>Week  number  of the current year,
              starting with the first Sunday as the first
              day of the first week (00..53)</td>
</tr>
<tr>
  <td>%W</td>
  <td>Week  number  of the current year,
              starting with the first Monday as the first
              day of the first week (00..53)</td>
</tr>
<tr>
  <td>%w</td>
  <td>Day of the week (Sunday is 0, 0..6)</td>
</tr>
<tr>
  <td>%x</td>
  <td>Preferred representation for the date alone, no time</td>
</tr>
<tr>
  <td>%X</td>
  <td>Preferred representation for the time alone, no date</td>
</tr>
<tr>
  <td>%y</td>
  <td>Year without a century (00..99)</td>
</tr>
<tr>
  <td>%Y</td>
  <td>Year with century</td>
</tr>
<tr>
  <td>%Z</td>
  <td>Time zone name</td>
</tr>
<tr>
  <td>%%</td>
  <td>Literal ``%'' character</td>
</tr>
<bottomrule/></table>
<p/>
    </figure>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_a" ref="to_a">
      <callseq>
        <obj>time</obj>.to_a
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a ten-element <obj>anArray</obj>
      of values for <obj>time</obj>: {<tt>[ sec, min, hour, day, month,
        year, wday, yday, isdst, zone ]</tt>}.  See the individual
      methods for an explanation of the valid ranges of each value.
      The ten elements can be passed directly to   <ccm><file>time</file><front>Time</front><back>utc</back><mref>utc</mref></ccm> or
      <ccm><file>time</file><front>Time</front><back>local</back><mref>local</mref></ccm> to create a new <classname>Time</classname>.
<p/>
<codefragment>
<fullcode><![CDATA[        now = Time.now
        t = now.to_a
]]></fullcode><rubycode>
<tr>
  <td><tt>now<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:21<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>now.to_a</tt></td>
  <td>&#187;</td>
  <td><tt>[21,<nbsp/>19,<nbsp/>0,<nbsp/>9,<nbsp/>6,<nbsp/>2002,<nbsp/>0,<nbsp/>160,<nbsp/>true,<nbsp/>"CDT"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_f" ref="to_f">
      <callseq>
        <obj>time</obj>.to_f
        <returns><obj>aFloat</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the value of <obj>time</obj> as a floating point number of
      seconds since epoch.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        "%10.5f" % t.to_f
        t.to_i
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
</tr>
<tr>
  <td><tt>"%10.5f"<nbsp/>%<nbsp/>t.to_f</tt></td>
  <td>&#187;</td>
  <td><tt>"1023599961.93824"</tt></td>
</tr>
<tr>
  <td><tt>t.to_i</tt></td>
  <td>&#187;</td>
  <td><tt>1023599961</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_i" ref="to_i">
      <callseq>
        <obj>time</obj>.to_i
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the value of <obj>time</obj> as an integer number of
      seconds since epoch.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        "%10.5f" % t.to_f
        t.to_i
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
</tr>
<tr>
  <td><tt>"%10.5f"<nbsp/>%<nbsp/>t.to_f</tt></td>
  <td>&#187;</td>
  <td><tt>"1023599962.01627"</tt></td>
</tr>
<tr>
  <td><tt>t.to_i</tt></td>
  <td>&#187;</td>
  <td><tt>1023599962</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_s" ref="to_s">
      <callseq>
        <obj>time</obj>.to_s
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a string representing <obj>time</obj>.  Equivalent to calling
      <cim><file>time</file><front>Time</front><back>strftime</back><mref>strftime</mref></cim> with a format string of 
        ``<tt>%a</tt> <tt>%b</tt> <tt>%d</tt> <tt>%H:%M:%S</tt> <tt>%Z</tt> <tt>%Y</tt>''.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.now.to_s
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.now.to_s</tt></td>
  <td>&#187;</td>
  <td><tt>"Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="tv_sec" ref="tv_sec">
      <callseq>
        <obj>time</obj>.tv_sec
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>to_i</back><mref>to_i</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
        <method name="tv_usec" ref="tv_usec">
      <callseq>
        <obj>time</obj>.tv_usec
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>usec</back><mref>usec</mref></cim>.
<p/>
      </desc>
    </method>
<p/>
       <method name="usec" ref="usec">
      <callseq>
        <obj>time</obj>.usec
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns just the number of microseconds for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        "%10.6f" % t.to_f
        t.usec
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>"%10.6f"<nbsp/>%<nbsp/>t.to_f</tt></td>
  <td>&#187;</td>
  <td><tt>"1023599962.174522"</tt></td>
</tr>
<tr>
  <td><tt>t.usec</tt></td>
  <td>&#187;</td>
  <td><tt>174522</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="utc" ref="utc">
      <callseq>
        <obj>time</obj>.utc <returns><obj>time</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <cim><file>time</file><front>Time</front><back>gmtime</back><mref>gmtime</mref></cim>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.utc?
        t.utc
        t.utc?
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.utc?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>t.utc</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>05:19:22<nbsp/>UTC<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.utc?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="utc?" ref="utc_qm">
      <callseq>
        <obj>time</obj>.utc? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>time</obj> represents a time in UTC (GMT).
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.utc?
        t = Time.gm(2000,"jan",1,20,15,1)
        t.utc?
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.utc?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.gm(2000,"jan",1,20,15,1)</tt></td>
  <td>&#187;</td>
  <td><tt>Sat<nbsp/>Jan<nbsp/>01<nbsp/>20:15:01<nbsp/>UTC<nbsp/>2000</tt></td>
</tr>
<tr>
  <td><tt>t.utc?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="wday" ref="wday">
      <callseq>
        <obj>time</obj>.wday
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an integer representing the day of the week, 0..6,
      with Sunday == 0.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.wday
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.wday</tt></td>
  <td>&#187;</td>
  <td><tt>0</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="yday" ref="yday">
      <callseq>
        <obj>time</obj>.yday
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an integer representing the day of the year, 1..366.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.yday
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.yday</tt></td>
  <td>&#187;</td>
  <td><tt>160</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="year" ref="year">
      <callseq>
        <obj>time</obj>.year
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the year for <obj>time</obj> (including the century).
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.now
        t.year
]]></fullcode><rubycode>
<tr>
  <td><tt>t<nbsp/>=<nbsp/>Time.now</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:22<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>t.year</tt></td>
  <td>&#187;</td>
  <td><tt>2002</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="zone" ref="zone">
      <callseq>
        <obj>time</obj>.zone
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the name of the time zone used for <obj>time</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        t = Time.gm(2000, "jan", 1, 20, 15, 1)
        t.zone
        t = Time.local(2000, "jan", 1, 20, 15, 1)
        t.zone
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.gm(2000,<nbsp/>"jan",<nbsp/>1,<nbsp/>20,<nbsp/>15,<nbsp/>1)</tt></td>
</tr>
<tr>
  <td><tt>t.zone</tt></td>
  <td>&#187;</td>
  <td><tt>"GMT"</tt></td>
</tr>
<tr>
<td colspan="3"><tt>t<nbsp/>=<nbsp/>Time.local(2000,<nbsp/>"jan",<nbsp/>1,<nbsp/>20,<nbsp/>15,<nbsp/>1)</tt></td>
</tr>
<tr>
  <td><tt>t.zone</tt></td>
  <td>&#187;</td>
  <td><tt>"CST"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>
