Ruby/Time/local
Материал из Wiki.crossplatform.ru
ArgumentError: time out of range
Time.local(1865, 4, 9) # ArgumentError: time out of range Time.local(2100, 1, 1) # ArgumentError: time out of range
Create Time.local
Time.local(1865,4,9) Time.local(2100,1,1)
The arguments to Time.local are (in order) year, month, date, hour, minutes, seconds. You can also call local with these arguments:
my_time = Time.local( 20, 15, 1, 30, "jan", 2007, 2, 30, false, "MST") # => Tue Jan 30 01:15:20 -0700 2007 # arguments are seconds, minutes, hour, day, month, year, day of the week, day of the year, is-it-daylight-savings-time?, and timezone.
The Time class allows you to create Time objects based on arbitrary dates:
# Time.local(year, month, day, hour, min, sec, msec) puts Time.local(2008, 8, 31, 2, 3, 4, 5)
To set a given time, use the local method (mktime is a synonym):
local_time = Time.local( 2007, "jan", 30, 1, 15, 20 ) puts local_time