$Web Date2D, $Web Date2N, $Web Date2ND, $Web Date2NM, $Web Date2NS: Difference between revisions
m (→Syntax) |
m (→Syntax) |
||
(15 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS}} | {{DISPLAYTITLE:$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS}} | ||
<span class="pageSubtitle" | <span class="pageSubtitle">$Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS: Convert date to number</span> | ||
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 <i>Greenwich Mean Time</i> (GMT). | |||
The $Web_Date2xx functions take three arguments and return a number. | The $Web_Date2xx functions take three arguments and return a number. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax">< | <p class="syntax"><span class="term">%DATETIME</span> = <span class="literal">$Web_Date2D</span>(<span class="term">date_string</span>, <span class="term">format</span>, <span class="term">centspan</span>) | ||
<span class="term">%DATETIME</span> = <span class="literal">$Web_Date2N</span>(<span class="term">date_string</span>, <span class="term">format</span>, <span class="term">centspan</span>) | |||
<span class="term">%DATETIME</span> = <span class="literal">$Web_Date2ND</span>(<span class="term">date_string</span>, <span class="term">format</span>, <span class="term">centspan</span>) | |||
< | |||
<span class="term">%DATETIME</span> = <span class="literal">$Web_Date2NM</span>(<span class="term">date_string</span>, <span class="term">format</span>, <span class="term">centspan</span>) | |||
<span class="term">%DATETIME</span> = <span class="literal">$Web_Date2NS</span>(<span class="term">date_string</span>, <span class="term">format</span>, <span class="term">centspan</span>) | |||
</p> | |||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>date_string</th> | <tr><th>date_string</th> | ||
<td>A string which contains a date and/or time, for example, | <td>A string which contains a date and/or time, for example, <code>07/12/64</code>, <code>January 5, 1984</code>, <code>19970822113025</code> and <code>12/31/1999 23:58:50</code>. This is a required argument.</td></tr> | ||
<tr><th>format</th> | <tr><th>format</th> | ||
<td>A string which contains the format of the date in | <td>A string which contains the format of the date in <var class="term">date_string</var>, 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: | |||
<ul> | |||
<li><tt>'Wkd, DD Mon YYYY HH:MI:SS "G"M"T'</tt> | |||
<li><tt>'Wkday, DD-Mon-YY HH:MI:SS "G"M"T'</tt> | |||
<li><tt>'Wkd Mon DAY HH:MI:SS YYYY'</tt> | |||
</ul> | |||
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|"Datetime string formats"]] for a description of the various Sirius datetime formats.</td></tr> | |||
<tr><th>centspan</th> | <tr><th>centspan</th> | ||
<td>The start of the century in which two digit years are assumed to fall. This can be absolute: <code>1980</code> 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. | |||
<var class="term">centspan</var> can also be relative: <code>-10</code> 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. | |||
<var class="term">centspan</var> is irrelevant when the date format contains four-digit years, and it defaults to -50 if not specified. | |||
This argument is ignored if the <var class="term">format</var> argument is missing; in that case, 1990 is used for <var class="term">centspan</var>. See [[Datetime string formats|"Datetime string formats"]] for a discussion of <var class="term">centspan</var> and other two-digit year date processing. | |||
</td></tr></table> | </td></tr></table> | ||
The time units returned by the | The time units returned by the $Web_Date2xx functions are: | ||
<table | <table> | ||
<tr><th>$Web_Date2D</th> | <tr><th>$Web_Date2D</th> | ||
<td>Number of seconds since midnight, January 1, 1900.</td></tr> | <td>Number of seconds since midnight, January 1, 1900.</td></tr> | ||
Line 44: | Line 59: | ||
<var>$Web_Date2D</var> produces identical results to <var>$Web_Date2NS</var>, so for clarity and consistency, it is recommended that <var>$Web_Date2NS</var> be used instead of <var>$Web_Date2D</var> since <var>$Web_Date2NS</var> indicates the time units being returned (number of seconds) and the format of the returned data (numeric). | |||
The $ | 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 | 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. | ||
<p class="code"> | <p class="code">For Each Record In CONTROL_REC | ||
%modtime = $web_date2NS(TIMESTAMP, 'YYYYMMDDHHMISS') | |||
End For | |||
%rc = $Web_Last_Modified(%modtime) | |||
</p> | </p> | ||
==See also== | |||
See also | |||
<ul> | <ul> | ||
<li>[[$Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS]] | <li><var>[[$Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS]]</var> | ||
<li>[[$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date]] | <li><var>[[$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date]]</var> | ||
</ul> | </ul> | ||
[[Category:Janus Web Server $functions|$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS]] | [[Category:Janus Web Server $functions|$Web_Date2D, $Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS]] |
Latest revision as of 02:16, 16 April 2013
$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:
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: 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)