$Web Date2D, $Web Date2N, $Web Date2ND, $Web Date2NM, $Web Date2NS: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS}} <span class="pageSubtitle"><section begin="desc" />$Web_Date2N, $Web_Date2ND, $Web_Date2NM, $W...")
 
m (1 revision)
(No difference)

Revision as of 21:38, 21 February 2011

<section begin="desc" />$Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS: Convert date to number<section end="desc" />


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:ehp1 (GMT).

Syntax

<section begin="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) <section end="syntax" />


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



date_string A string which contains a date and/or time, for example, &OSQ.07/12/64&CSQ., &OSQ.January 5, 1984&CSQ., &OSQ.19970822113025&CSQ. and &OSQ.12/31/1999 23:58:50&CSQ.. 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 - &OSQ.Wkd, DD Mon YYYY HH:MI:SS "G"M"T&CSQ., &OSQ.Wkday, DD-Mon-YY HH:MI:SS "G"M"T&CSQ., &OSQ.Wkd Mon DAY HH:MI:SS YYYY&CSQ.. 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 the chapter titled Datetime Processing Considerations in the &SFUNCR. 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 that a year 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 that in 2001 a year 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 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 the chapter titled Datetime Processing Considerations in the Sirius Functions Reference Manual for a discussion of centspan and other 2-digit year date processing.


The time units returned by the various flavors of $WEB_DATE2xx 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.


Only $Web_Date2D was available before Version 4.6 of the Sirius Mods. $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 &OSQ.YYYYMMDDHHMISS:CSQ. format.

FOR EACH RECORD IN CONTROL_REC %MODTIME = $WEB_DATE2NS(TIMESTAMP, - 'YYYYMMDDHHMISS') END FOR %RC = $Web_Last_Modified(%MODTIME)


See also $Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS and $Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date.