Package =TWiki::TimeTime handling functions. | |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | StaticMethod parseTime ($szDate) -> $iSecs | ||||||||||||||||||||||||||||||
> > | StaticMethod parseTime ($szDate,$defaultLocal) -> $iSecs | ||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | Convert string date/time to seconds since epoch. | ||||||||||||||||||||||||||||||
> > | Convert string date/time string to seconds since epoch (1970-01-01T00:00:00Z). | ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > |
| ||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > | ISO dates may have a timezone specifier, either Z or a signed difference in hh:mm format. For example: | ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < |
| ||||||||||||||||||||||||||||||
> > | The default timezone is Z, unless $defaultLocal is true in which case | ||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > | the local timezone will be assumed. | ||||||||||||||||||||||||||||||
If the date format was not recognised, will return 0.
StaticMethod formatTime ($epochSeconds,$formatString,$outputTimeZone) -> $value | |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
$formatString supports:
| |||||||||||||||||||||||||||||||
Added: | |||||||||||||||||||||||||||||||
> > | |||||||||||||||||||||||||||||||
StaticMethod formatDelta ($s) -> $stringFormat a time in seconds as a string. For example, "1 day, 3 hours, 2 minutes, 6 seconds"StaticMethod parseInterval ($szInterval) -> [$iSecs,$iSecs]Convert string representing a time interval to a pair of integers representing the amount of seconds since epoch for the start and end extremes of the time interval.
interval ::= date { $$.start = fillStart($1); $$.end = fillEnd($1); } | date '/' date { $$.start = fillStart($1); $$.end = fillEnd($3); } | 'P' duration '/' date { $$.start = fillEnd($4)-$2; $$.end = fillEnd($4); } | date '/' 'P' duration { $$.start = fillStart($1); $$.end = fillStart($1)+$4; } ;an interval may be followed by a timezone specification string (this is not supported yet).
duration has the form (regular expression):
P(<number><nameOfDuration>)+nameOfDuration may be one of:
date follows ISO8601 and must include hypens. (any amount of trailing
elements may be omitted and will be filled in differently on the
differents ends of the interval as to include the longest possible
interval):
| |||||||||||||||||||||||||||||||
Changed: | |||||||||||||||||||||||||||||||
< < | timezone is optional and not supported yet. | ||||||||||||||||||||||||||||||
> > | timezone is optional. Default is local time. | ||||||||||||||||||||||||||||||
If the format is not recognised, will return empty interval [0,0]. TODO: timezone testing, especially on non valid strings |
Package =TWiki::TimeTime handling functions.On this page:
StaticMethod parseTime ($szDate) -> $iSecsConvert string date/time to seconds since epoch.
StaticMethod formatTime ($epochSeconds,$formatString,$outputTimeZone) -> $value
$formatString supports:
StaticMethod formatDelta ($s) -> $stringFormat a time in seconds as a string. For example, "1 day, 3 hours, 2 minutes, 6 seconds"StaticMethod parseInterval ($szInterval) -> [$iSecs,$iSecs]Convert string representing a time interval to a pair of integers representing the amount of seconds since epoch for the start and end extremes of the time interval.
interval ::= date { $$.start = fillStart($1); $$.end = fillEnd($1); } | date '/' date { $$.start = fillStart($1); $$.end = fillEnd($3); } | 'P' duration '/' date { $$.start = fillEnd($4)-$2; $$.end = fillEnd($4); } | date '/' 'P' duration { $$.start = fillStart($1); $$.end = fillStart($1)+$4; } ;an interval may be followed by a timezone specification string (this is not supported yet).
duration has the form (regular expression):
P(<number><nameOfDuration>)+nameOfDuration may be one of:
date follows ISO8601 and must include hypens. (any amount of trailing
elements may be omitted and will be filled in differently on the
differents ends of the interval as to include the longest possible
interval):
|