Definition: |
include builtins\timedate.e
timedate identifier -- or -- integer i = timedate(object x) |
Description: | This serves to define the timedate type. You can also call it like an ordinary function to determine if an object is an timedate. |
Comments: |
A timedate can hold the result from date() and a successful call to
parse_date_string(), and can be modified using
adjust_timedate(),
set_timezone(), and
change_timezone().
The DT_XXX constants as defined in the date() documentation can be used to examine the contents of a timedate.
Internally, a timedate is a sequence of between 8 and 10 integers, depending on whether it has a timezone. The result from date() is a valid timedate, without a timezone, as is {0,0,0,0,0,0,0,0}. This type is intended to speed development by trapping errors (eg "number expected") faster, as opposed to catching partial or unusable values. Attempts to parse say "3:15pm" must clearly leave day/month/year as zero, so any validation cannot be too fussy. It will however trigger a typecheck failure if the month/day/hour/minute/second/dayofweek/dayofyear/timezone are outside 0..12/31/23/59/59/7/366/length(timezones) respectively. When invoked as a function, returns 1 if x is a timedate otherwise returns 0. To quietly catch errors from parse_date_string(), store the result in a sequence variable and either use the timedate function to test it or check that the length() is not 3 before attempting to use it as a timedate. |
Example: |
include builtins\timedate.e timedate td = parse_date_string("1/1/2001",{"D/M/YYYY"}) ?format_timedate(td,"Dddd, Mmmm dth, yyyy") -- displays "Monday, January 1st, 2001" |
See Also: | date, length, parse_date_string, adjust_timedate, set_timezone, change_timezone, format_timedate |