The time utilities object ($core.utility.time) defines verbs that manipulate representations of time.
INT $core.utility.time:make_time(INT year, INT month, INT day, INT hour, INT minute, INT second, INT zone)
Makes an epoch time from time components.
$core.utility.time:make_time(1970, 01, 01, 00, 00, 00, 0) => 0
$core.utility.time:make_time(2012, 11, 10, 09, 08, 07, 6) => 1352560087
INT $core.utility.time:parse_ctime(STR time)
Parses ctime format time string and returns an epoch time.
$core.utility.time:parse_ctime("Sun Nov 11 06:18:32 1990 EST") => 658322312
INT $core.utility.time:parse_w3c_time(STR time)
Parses W3C format time string and returns an epoch time.
$core.utility.time:parse_w3c_time("2008-09-15T15:53:01+05:30") => 1221513781
STR $core.utility.time:english_time([INT time [, INT reference]])
Returns an English language description of the difference in time between time and reference. If time is not specified it defaults to the current time. If reference is not specified it defaults to zero (the epoch).
$core.utility.time:english_time() => "43 years, 20 days, 41 minutes and 16 seconds"
$core.utility.time:english_time(658322312) => "20 years, 10 months, 10 days, 11 hours, 18 minutes and 32 seconds"
$core.utility.time:english_time(658322312, 658322311) => "1 second"
INT $core.utility.time:now()
Returns the current time.
$core.utility.time:now() => 1363708535
STR $core.utility.time:string_month([INT time])
Returns the name of the current month, or the month for the specified time.
$core.utility.time:string_month(1363708535) => "March"
STR $core.utility.time:string_day([INT time])
Returns the name of the current day of the week, or the day for the specified time.
$core.utility.time:string_day(1363708535) => "Tuesday"
INT $core.utility.time:year([INT time])
INT $core.utility.time:month([INT time])
INT $core.utility.time:day([INT time])
INT $core.utility.time:hour([INT time])
INT $core.utility.time:minute([INT time])
INT $core.utility.time:second([INT time])
Returns the numeric representation of the current time component (year, month, etc.), or the component for the specified time.
$core.utility.time:year(1363708535) => 2013
$core.utility.time:day(1363708535) => 19
INT $core.utility.time:is_am([INT time])
INT $core.utility.time:is_pm([INT time])
Returns true if the specified time is AM or PM, as appropriate. If time is not specified, it defaults to the current time.
$core.utility.time:is_am(1363708535) => 1
$core.utility.time:is_pm(1363708535) => 0
STR $core.utility.time:zone([INT time])
Returns the abbreviation of the current time zone, or of the time zone for the specified time.
$core.utility.time:zone() => "EDT"
INT $core.utility.time:is_dst([INT time])
Returns true if daylight savings time is in effect for the specified time. If time is not specified, it defaults to the current time.
$core.utility.time:is_dst(1363708535) => 1
INT $core.utility.time:is_sunday([INT time])
INT $core.utility.time:is_monday([INT time])
INT $core.utility.time:is_tuesday([INT time])
INT $core.utility.time:is_wednesday([INT time])
INT $core.utility.time:is_thursday([INT time])
INT $core.utility.time:is_friday([INT time])
INT $core.utility.time:is_saturday([INT time])
Returns true if the specified time is the indicated day of week, as appropriate. If time is not specified, it defaults to the current time.
$core.utility.time:is_sunday(1363708535) => 0
$core.utility.time:is_tuesday(1363708535) => 1
STR $core.utility.time:format(STR format, [INT time, [INT gmt]])
Formats the current time, or the specified time, according to the specified format string. By default, the verb operates in the current time zone. The optional gmt flag forces the conversion to GMT/UTC. Within the formatting string, the following character sequences have special meaning.
$$ => $ $H => hours, 24-hour, zero-padded (09) $h => hours, 24-hour, unpadded (9) $M => minutes, zero-padded (08) $m => minutes, unpadded (8) $S => seconds, zero-padded (07) $s => seconds, unpadded (7) $O => hours, 12-hour, zero-padded (07) $o => hours, 12-hour, unpadded (7) $Y => year, four-digit (2013) $y => year, two-digit (13) $N => month, full (January) $n => month, abbreviated (Jan) $B => month, numeric, zero-padded (01) $b => month, numeric, unpadded (1) $C => month, numeric, space-padded ( 1) $c => month, numeric, unpadded (1) $D => day of week, full (Wednesday) $d => day of week, abbreviated (Wed) $T => day, zero-padded (02) $t => day, unpadded (2) $U => day, space-padded ( 2) $u => day, unpadded (2) $P => am/pm, uppercase (PM) $p => am/pm, lowercase (pm) $Z => timezone, numeric (+05:00) $z => timezone, abbreviated (EST) $w => week of year (1) $j => day of year (35)
Examples:
$core.utility.time:format("$d, $T $n $Y $H:$M:$S $z", 1363708535, 0) => "Tue, 19 Mar 2013 11:55:35 EDT"
$core.utility.time:format("$Y-$B-$TT$H:$M:$SZ", 1363708535, 1) => "2013-03-19T15:55:35Z"
STR $core.utility.time:rfc1123_time([INT time])
Returns the RFC 1123 format time. If time is not specified, it defaults to the current time.
$core.utility.time:rfc1123_time() => "Tue, 19 Mar 2013 11:55:35 EDT"
STR $core.utility.time:w3c_time([INT time])
Returns the W3C (ISO 8601) format time. If time is not specified, it defaults to the current time.
$core.utility.time:w3c_time() => "2013-03-19T15:55:35Z"