$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS

From m204wiki
Jump to navigation Jump to search

$Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS: Convert date to number

The $Web_Date2xx functions convert date/time strings into numbers. The returned value is always in time units since 12 AM on January 1, 1900 in Greenwich Mean Time (GMT).

The $Web_Date2xx functions take three arguments and return a number.

Syntax

%DATETIME = $Web_Date2D(date_string, format, centspan) %DATETIME = $Web_Date2N(date_string, format, centspan) %DATETIME = $Web_Date2ND(date_string, format, centspan) %DATETIME = $Web_Date2NM(date_string, format, centspan) %DATETIME = $Web_Date2NS(date_string, format, centspan)

Syntax terms

date_string A string which contains a date and/or time, for example, 07/12/64, January 5, 1984, 19970822113025 and 12/31/1999 23:58:50. This is a required argument.
format A string which contains the format of the date in date_string, for example, 'MM/DD/YY', 'Month DAY, YYYY', 'YYYYMMDDHHMISS' and 'MM/DD/YYYY HH:MI:SS'.

This is not a required argument. If it is not specified, the format of the date string is assumed to be one of the three standard web date formats:

  • 'Wkd, DD Mon YYYY HH:MI:SS "G"M"T'
  • 'Wkday, DD-Mon-YY HH:MI:SS "G"M"T'
  • 'Wkd Mon DAY HH:MI:SS YYYY'

In this case, the date string is assumed to already be in GMT. In all other cases, the date string is assumed to be in local time and so is converted to GMT.

See "Datetime string formats" for a description of the various Sirius datetime formats.
centspan The start of the century in which two digit years are assumed to fall. This can be absolute: 1980 means that two-digit years are assumed to fall between 1980 and 2079, so a year value of 94 is assumed to mean 1994, and a year of 75 is assumed to mean 2075.

centspan can also be relative: -10 means that two-digit years are assumed to fall between 10 years ago and 90 years hence, so in 2001 a year value of 93 is assumed to mean 1993, and a year of 87 is assumed to mean 2087.

centspan is irrelevant when the date format contains four-digit years, and it defaults to -50 if not specified.

This argument is ignored if the format argument is missing; in that case, 1990 is used for centspan. See "Datetime string formats" for a discussion of centspan and other two-digit year date processing.


The time units returned by the $Web_Date2xx functions are:

$Web_Date2D Number of seconds since midnight, January 1, 1900.
$Web_Date2N Number of seconds since midnight, January 1, 1900.
$Web_Date2ND Number of days since midnight, January 1, 1900.
$Web_Date2NM Number of milliseconds since midnight, January 1, 1900.
$Web_Date2NS Number of seconds since midnight, January 1, 1900.


$Web_Date2D produces identical results to $Web_Date2NS, so for clarity and consistency, it is recommended that $Web_Date2NS be used instead of $Web_Date2D since $Web_Date2NS indicates the time units being returned (number of seconds) and the format of the returned data (numeric).

The $Web_Date2xx functions provide a convenient way of converting date and time stamps into a numeric format convenient for web processing. For example, the following chunk of code sets a last-modified time for a URL associated with a record from a timestamp in the file that is in local 'YYYYMMDDHHMISS' format.

For Each Record In CONTROL_REC %modtime = $web_date2NS(TIMESTAMP, 'YYYYMMDDHHMISS') End For %rc = $Web_Last_Modified(%modtime)

See also