xcall IDTIM, stringfmt, idate, itime, flags, status
IDTIM.SBR converts a string format date and/or time into so called internal format. (Internal format dates are also referred to as separated format, and is the format returned by the DATE system function. Internal format time is simply the number of seconds since midnight.) The inverse function is ODTIM, which converts an internal format date and/or time to a string format.
Parameters
stringfmt
should be set to the date and/or time be converted, with the time following the date (with a space separator) if both date and time are included. (Also see flags parameter, which indicates if date and/or time are present.) The date, if present, should be in MM-DD-{CC}YY or DD-MM-{CC}YY format, depending on your language definition file specification for date order. The separator character, however, need not be a dash or even match the language definition file; it can be any non-numeric character. The time format is HH:MM{:SS} {AM/PM}. Legal examples would be:
12/30/07 13:01
01-01-2007 10:15:33 PM
23:01:10
05.03.1915
If only two digits are specified for the year, it is assumed to be in the twentieth century (19xx) unless the SBR=CCYY statement is included in miame.ini, in which case it will determine the YY cutoff below which we assume 20xx instead of 19xx.
idate (F,6)
will return the internal format date, or zero if the date is not included in the input string. Note, however, that to access the individual separated fields within it, you need to assign the F,6 value to a B,4 which is mapped on top of the separated date structure, as in the following example:
MAP1 Sepdate
MAP2 Mon,B,1 ! Month 1-12
MAP2 Day,B,1 ! Day 1-31
MAP2 Yr,B,1 ! Year-1900
MAP2 Dow,B,1 ! Day of week (0=Mon, 6=Sun)
MAP1 Bdate,B,4,@Sepdate ! B,4 version of Sepdate, as used by
! the DATE system function
MAP1 Idate,F,6 ! F,6 version as needed by IDTIM
xcall IDTIM, StringFmt, Idate, Itime, Flags, Status
Bdate = Idate
Print "Separated date: ";Mon;Day;Yr;Dow
Bdate = DATE ! Get today's date (for comparison)
Print "Today's separated date: ";Mon;Day;Yr;Dow
itime (F,6)
will return the internal format time (i.e. seconds since midnight) or zero if the time is not present.
flags (Num)
should be set to 0 to process both the date and time; 1 if the string is expected to contain only the time, and 2 if it is expected to contain only the date.
status (F,6)
will return a code of 0 to indicate a successful conversion, or –1 to indicate an error (such as an invalid format or invalid date).
History
2011 September, A-Shell 5.1.1232: Flag +4 allows the hh value to be greater than 24. Mainly useful for verifying validity of an elapsed number of hours. The returned internal time will still be just the seconds since the last midnight.