$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date

From m204wiki
Revision as of 21:38, 21 February 2011 by Admin (talk | contribs) (1 revision)
Jump to navigation Jump to search

<section begin="desc" />$Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date: Convert number to date<section end="desc" />


The $WEB_xx2DATE functions convert a numeric date/time value into date/time strings. The returned string is in the format "Wkd, DD Mon YYYY HH:MI:SS GMT". The $WEB_xx2DATE functions take one argument and return a string or null in the event of a conversion error.

Syntax

<section begin="syntax" /> %DATESTRING = $Web_D2Date(datetime) %DATESTRING = $Web_N2Date(datetime) %DATESTRING = $Web_ND2Date(datetime) %DATESTRING = $Web_NM2Date(datetime) %DATESTRING = $Web_NS2Date(datetime) <section end="syntax" />


$WEB_xx2DATE takes one argument and returns a string.

datetime This is the number of time units since 12 AM, January 1, 1900. The time is assumed to be in Greenwich Mean Time (GMT). This is a required parameter.


The input time units for the various flavors of $WEB_xx2DATE are ;

$Web_D2Date Number of seconds since midnight, January 1, 1900.
$Web_N2Date Number of seconds since midnight, January 1, 1900.
$Web_ND2Date Number of days since midnight, January 1, 1900.
$Web_NM2Date Number of milliseconds since midnight, January 1, 1900.
$Web_NS2Date Number of seconds since midnight, January 1, 1900.


Only $Web_D2Date was available before Version 4.6 of the Sirius Mods. $Web_D2Date produces identical results to $Web_NS2Date so, for clarity and consistency, it is recommended that $Web_NS2Date be used instead of $Web_D2Date since $Web_NS2Date indicates the time units for the input (number of seconds) and the format of the input data (numeric).

The most likely uses of these functions is for displaying debugging information (perhaps to the audit rail) or setting an HTTP response header parameter that requires a web time value, though most of the useful response headers are better accessed through special purpose $functions such as $Web_Expire and $Web_Last_Modified. In the following example, the HTTP 1.1 response header called "Retry-After" is set as two minutes later.

%CURR_TIME = $Web_DateNS %RETRY_TIME = $Web_NS2Date(%CURR_TIME + 2 * 60) %RC = $Web_Response('Retry-After', - %RETRY_TIME)

Even this example is a bit of a stretch, since the value for "Retry-After" can be expressed as a number of seconds later instead of a date/time string.

See also: