Configuring Gen for date and time command usage is optional. Gen is preconfigured to use the following formats:
%Y-%m-%d -> 2000-01-02, 2009-08-07, etc.
%Y-%m-%d %H:%M:%S -> 2000-01-02 03:04:05, 2009-08-07 06:05:04, etc.
%H:%M:%S -> 00:01:02, 12:13:14, etc.
Gen currently uses the clock
command as its basis for date and time commands. Configuring Gen for date and time commands means telling it what to use for flags in its arguments to the clock command. For instance, if we say:
SetDateFormat %Y-%m-%d IsDate 2000-01-02... then Gen, within
IsDate
, will make a call to clock scan 2000-01-02 -format %Y-%m-%d
.
Note that the contents of GenNS::DateFormat
, GenNS::DatetimeFormat
, and GenNS::TimeOfDateFormat
will be appended to strings of the form clock format $Seconds -format
or clock scan {$String} -format
before making the call. This means that you will want to group arguments with braces {} and will also want to include flags for timezone, locale, etc. The following examples will make this more clear.
Call SetDateFormat
with the format to use in date commands (e.g. DateIsOn
). For example:
% SetDateFormat %Y-%m-%d
% Today
2000-01-02
% SetDateFormat {{%B %d, %Y}}
% Today
January 01, 2000
Call SetDatetimeFormat
with the format to use in datetime commands (e.g. DatetimeIsAt
). For example:
% SetDatetimeFormat {%Y-%m-%d %H:%M:%S}
% Now
2000-01-02 03:04:05
% SetDatetimeFormat {{%m/%d/%Y %H:%M} -locale en_US -timezone :America/New_York}
% Now
01/02/2000 03:04
Call SetTimeOfDayFormat
with the format to use in time-of-day commands (e.g. TimeOfDayIsAt
). For example:
% SetTimeOfDayFormat %H:%M:%S
% CurrentTimeOfDay
12:11:10
% SetTimeOfDayFormat {{%I%M %p} -timezone :America/New_York -locale en_US}
% CurrentTimeOfDay
1211 PM