$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...")
 
 
(19 intermediate revisions by 5 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"><section begin="desc" />$Web_Date2N, $Web_Date2ND, $Web_Date2NM, $Web_Date2NS: Convert date to number<section end="desc" /></span>
<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 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==
==Syntax==
<p class="syntax"><section begin="syntax" /> %DATETIME = $Web_Date2D(date_string, format, centspan)
<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>)
%DATETIME = $Web_Date2N(date_string, format, centspan)
 
%DATETIME = $Web_Date2ND(date_string, format, centspan)
<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>)
%DATETIME = $Web_Date2NM(date_string, format, centspan)
 
%DATETIME = $Web_Date2NS(date_string, format, centspan)
<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>)
<section end="syntax" /></p>
 
<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>


The $Web_Date2xx functions take three arguments and return a number.
===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, &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.</td></tr>
<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 ''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.</td></tr>
<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>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.
</td></tr></table>
</td></tr></table>




The time units returned by the various flavors of $WEB_DATE2xx are :
The time units returned by the $Web_Date2xx functions are:
<table class="syntaxTable">
<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:




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).  
<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 $WEB_DATE2xx functions provide a convenient way of converting date and time stamps into a numeric format convenient for web processing.
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 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"> FOR EACH RECORD IN CONTROL_REC
<p class="code">For Each Record In CONTROL_REC
%MODTIME = $WEB_DATE2NS(TIMESTAMP, -
%modtime = $web_date2NS(TIMESTAMP, 'YYYYMMDDHHMISS')
'YYYYMMDDHHMISS')
End For
END FOR
%rc = $Web_Last_Modified(%modtime)
%RC = $Web_Last_Modified(%MODTIME)
</p>
</p>


 
==See also==
See also [[$Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS]] and [[$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date]].
<ul>
<li><var>[[$Web_Date, $Web_DateND, $Web_DateNM, and $Web_DateNS]]</var>
<li><var>[[$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date]]</var>
</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:

  • '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