|
prev
-
up
-
next
-
index
-
Time
-
The Time class represents the time value and its
operations. Time.now returns the current time object.
The timestamps of the files returned by
File#stat are instances of
this class.
-
SuperClass:
-
-
Object
-
Included Modules:
-
-
Comparable
-
Class Methods:
-
-
now
-
-
now
-
Returns the current time object.
-
at(time)
-
Creates the time object at time. The argument
time must be either the instance of the Time
class or the number, which is considered as seconds since
00:00:00 GMT, January 1, 1970.
-
gm(year, month, day, hour, min, sec)
-
Returns the Time object specified by the arguments in GMT.
The arguments after the second one can be omitted. The default value
for the omitted argument is the lowest value for that argument.
If the month argument is a fixnum, it must be from
1(January) to 12(December). If it is string, it must be the English
month name or the number starting from 1(January) to 12(December).
If the number of arguments are equals to that of elements of
Time#to_a, Time.gm understands them
properly, even if they are in the little endian (seconds comes first)
format.
-
local(year, month, day, hour, min, sec)
-
-
mktime(year, month, day, hour, min, sec)
-
Returns the Time object specified by the arguments in localtime.
The arguments after the second one can be omitted. The default value
for the omitted argument is the lowest value for that argument.
-
times
-
Returns the user and system CPU times structure, which attributes are:
utime # user time
stime # system time
cutime # user time of children
cstime # system time of children
Times are floating-point numbers and are measured in seconds.
(See times(3))
-
Methods:
-
-
self + other
-
Returns the time object which is later than self by
other.
-
self - other
-
Returns the diff of the time in float, if the other if the
time object. If the other is the numeric value, it returns
the time object earlier than self than other.
-
self <=> other
-
Comparison of the times. other must be a time object or an
integer or a floating-point number. Numbers are considered as seconds
since 00:00:00 GMT, January 1, 1970.
-
asctime
-
ctime
-
to_s
-
Converts the time into the string form like ctime(3).
-
gmtime
-
Sets timezone of the time object to GMT. The time object
operates time in GMT thereafter. To print time in GMT:
print Time.now.gmtime, "\n"
gmtime returns self .
-
localtime
-
Sets timezone of the time object to localtime, which is default.
Returns time object itself.
-
to_i
-
tv_sec
-
Returns the time since the epoch,
00:00:00 GMT, January 1, 1970,
measured in seconds.
-
sec
-
min
-
hour
-
mday
-
day
-
mon
-
month
-
year
-
wday
-
yday
-
zone
-
isdst
-
Returns the internal values of the time object. All methods return an
integer value, except zone , which returns the timezone name
string. (c.f. localtime(3))
Notice: Unlike tm struct, month returns 1 for January, year
returns 1998 for year 1998, and yday start with 1 (not 0).
-
strftime(format)
-
Returns formatted string from the time object. Format specifiers are
as follows:
-
%A
- full weekday name(Sunday, Monday...)
-
%a
- abbreviated weekday name(Sun, Mon...)
-
%B
- full month name(January, February...)
-
%b
- abbreviated month name(Jan, Feb...)
-
%c
- date and time representation
-
%d
- day of the month in decimal(01-31)
-
%H
- hour using a 24-hour clock(00-23)
-
%I
- hour using a 12-hour clock(01-12)
-
%j
- day of the year(001-366)
-
%M
- minutes(00-59)
-
%m
- month in decimal(01-12)
-
%p
- Either AM or PM
-
%S
- second in decimal(00-61)
-
%U
- week number, first Sunday as the first day of the first week(00-53)
-
%W
- week number, first Monday as the first day of the first week(00-53)
-
%w
- day of the week in number. Sunday being 0(0-6)
-
%X
- time representation without date
-
%x
- date representation without time
-
%Y
- year
-
%y
- year without century(00-99)
-
%Z
- timezone
-
%%
- %itself
-
to_a
-
Converts tm struct into an array, whose elements are in
order of:
- sec
- min
- hour
- mday
- mon
- year
- wday
- yday
- isdst
- zone
-
to_f
-
Converts the time (in seconds from the epoch) into a floating-point
number.
-
usec
-
tv_usec
-
Returns micro second part of the time object.
prev
-
up
-
next
-
index
matz@netlab.co.jp
|