Timezone dependent time library using tzfile.
TZFile.create generate a class which is similar to the Time class.
TokyoTime = TZFile.create("Asia/Tokyo") p TokyoTime.now p TokyoTime.local(2001,4,19) p TokyoTime.utc(2000,3,20)
Since this library uses tzfile format, it doesn't work on platforms which doesn't provide timezone information by tzfile format. The format is primarily supported by tzcode/tzdata package <URL:ftp://elsie.nci.nih.gov/pub/> and the Theory file in tzcode says:
This package is already part of many POSIX-compliant hosts, including BSD, HP, Linux, Network Appliance, SCO, SGI, and Sun.
Since 32bit signed integer is used to specify a number of seconds from the Epoch (1970/01/01 00:00:00 UTC) in the format, tzfile can provide timezone information only between December 1901 and January 2038. Thanks to Ruby's Bignum and object oriented polymorphism, this library doesn't cause overflow exception even if a time is out of the range. This library uses first timezone information for before 1901 and last timezone information for after 2038. But this means results may incorrect. For example, if January 2038 is in DST (daylight saving time) - remember that January is summer in the south half of the globe -, DST is applied forever after 2038. So, don't use this library under such condition.
TZFile.create(path)
Creates a timezone class by timezone file specified by "path". If "path" is relative, it is interpreted as a relative path from platform dependent timezone directory.
The generated class behaves like Time class.
TZFile.zoneinfo_directory
TZFile.each([directory]) {|name, tzfile| ...}
Following methods can be used as class methods of a class generated by TZFile.create because TZFile extends the class.
at(time)
utc(year[, mon[, mday[, hour[, min[, sec]]]]])
utc(sec, min, hour, mday, mon, year, wday, yday, isdst, zone)
gm(year[, mon[, mday[, hour[, min[, sec]]]]])
gm(sec, min, hour, mday, mon, year, wday, yday, isdst, zone)
local(year[, mon[, mday[, hour[, min[, sec]]]]])
local(sec, min, hour, mday, mon, year, wday, yday, isdst, zone)
mktime(year[, mon[, mday[, hour[, min[, sec]]]]])
mktime(sec, min, hour, mday, mon, year, wday, yday, isdst, zone)
now
each_range {|time1, timetype, time2| ...}
Evaluate the block for each time range. "time1" is a beginning of the time range. "time2" is a beginning of the next time range. "timetype" is a time type applied between "time1" and "time2".
For first time range, time1 is true. For last time range, time2 is false.
each_transition {|timetype1, time, timetype2| ...}
each_closed_range {|time1, timetype, time2| ...}
each_timetype {|timetype| ...}
count_leapseconds(time[, direction])
uncount_leapseconds(time)
Convert an integer "time" to an array which has three elements: [t, s, d]. "t" corresponds to "time" but leapseconds are not counted. "s" specifies the type of the previous leapsecond: -1, 1, 0 for deletion, insertion, not exists. "d" is a number of seconds from the previous leapsecond. If the previous leapsecond is not exists, "d" is -1.
If "time" points an inserted leapsecond, "t" corresponds to "time-1", "s" is 1 and "d" is 0.
If "time" is just after a deleted leapsecond, "d" is 1.
The superclass of a class generated by TZFile.create.
self + other
self - other
self <=> other
utc?
gmt?
utc
gmtime
getutc
getgm
localtime
getlocal
strftime(format)
Format the time.
Note that this method is locale independent - always POSIX locale style. `E' and `O' modifier is accepted but ignored.
sec
min
hour
mday
day
mon
month
year
wday
yday
zone
isdst
dst?
utc_offset
gmt_offset
gmtoff
to_i
tv_sec
to_s
to_a
utc_offset
gmt_offset
gmtoff
isdst
abbrind
isstd
isgmt
abbrev
gmtoff_str
to_s