About Date and Time Commands

Configuring Gen for date and time command usage is optional. Gen is preconfigured to use the following formats:

  1. Date: %Y-%m-%d -> 2000-01-02, 2009-08-07, etc.
  2. Datetime: %Y-%m-%d %H:%M:%S -> 2000-01-02 03:04:05, 2009-08-07 06:05:04, etc.
  3. TimeOfDay: %H:%M:%S -> 00:01:02, 12:13:14, etc.
But if you like, you can configure the formats Gen will expect and use for date, time, and datetime strings.

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.

1. Date Format

Call SetDateFormat with the format to use in date commands (e.g. DateIsOn). For example:

  1. % SetDateFormat %Y-%m-%d
    % Today
    2000-01-02
  2. % SetDateFormat {{%B %d, %Y}}
    % Today
    January 01, 2000

2. Datetime Format

Call SetDatetimeFormat with the format to use in datetime commands (e.g. DatetimeIsAt). For example:

  1. % SetDatetimeFormat {%Y-%m-%d %H:%M:%S}
    % Now
    2000-01-02 03:04:05
  2. % SetDatetimeFormat {{%m/%d/%Y %H:%M} -locale en_US -timezone :America/New_York}
    % Now
    01/02/2000 03:04

3. Time Of Day Format

Call SetTimeOfDayFormat with the format to use in time-of-day commands (e.g. TimeOfDayIsAt). For example:

  1. % SetTimeOfDayFormat %H:%M:%S
    % CurrentTimeOfDay
    12:11:10
  2. % SetTimeOfDayFormat {{%I%M %p} -timezone :America/New_York -locale en_US}
    % CurrentTimeOfDay
    1211 PM