date, compiled-date
Full Description
swirl
Syntax
  date string-expression

  OR

  compiled-date string-expression


Purpose

date returns the current date and time.

compiled-date returns the date and time taken when the OmniMark program was compiled.

The date and compiled-date operators must be followed by a string expression that can contain ordinary characters, format items, and date format items. Ordinary characters are passed through unchanged, and the format items are replaced with the appropriate values.

For example, the following process rule will output the current date in a "YY/MM/DD" format, and it will output the time the program was compiled in an "HH:MM:SS" format:

  process
     local stream today
     local stream comptime

     set today to date "=Y/=M/=D%n"
     output today || "%n"
     set comptime to compiled-date "=h:=m:=s%n"
     output comptime || "%n"

The equals sign (=) is the first character in a date format item, akin to the percent sign (%) that is the first character in a regular format item. The slash and colon characters that appear in this example are regular characters which pass through unchanged to the appropriate variable.

Date format items begin with an "=" character and have the following meanings:

  • "==", the equals ("=") character itself
  • "=a", a lowercase letter indicating morning or afternoon/evening ("a" for the first 12 hours of the day, "p" for the second 12 hours of the day)
  • "=A", an uppercase letter indicating morning or afternoon/evening ("A" for the first 12 hours of the day, "P" for the second 12 hours of the day)
  • "=n", the English name of the month with the first letter capitalized and all the others not (for example, "December")
  • "=t", the offset in hours and minutes from Greenwich Mean Time (for example, date "=t+" will produce the string "-0500" in the Eastern Standard Time zone)
  • "=w", the English name of the day of the week with the first letter capitalized and all the others not (for example, "Tuesday")
  • "= x? H", the hour of the day in 24-hour form
  • "= x? h", the hour of the day in 12-hour form
  • "= x? m", the minute of the hour
  • "= x? s", the second of the hour (without a fraction)
  • "= x? S", the second of the minute (with a fraction, when available from the system on which the program is running)
  • "= x? Y", the year
  • "= x? M", the number of the month (January = 1, December = 12)
  • "= x? D", the number of the day of the month

Specifying the "x" modifier, as shown in the above list, causes the OmniMark program to return as few or as many digits as necessary to provide accurate and complete information. If you leave the "x" qualifier out, everything will be presented with two digits. For example, the date February 29, 1996 would be represented as follows:

  • "=M/=D/=Y" will produce the date "02/29/96"
  • "=xM/=xD/=xY" will produce the date "2/29/1996"

Without the "x", single-digit values are zero padded, two-digit values appear as is, and a four-digit year appears in a two-digit field, so its leading two digits are truncated. (In the case of year-2000-related digression, when you use "=xY" you'll always get the correct year, as long as your underlying system is year-2000 compliant. If you use "=Y", your code may suffer problems after December 31, 1999; this largely depends on whether you're producing data intended for another program.)

Copyright © OmniMark Technologies Corporation, 1988-1998.