$Sir NS2Date: Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 4: | Line 4: | ||
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Sir_NS2Date function.</p> | <p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Sir_NS2Date function.</p> | ||
The $Sir_NS2Date function expects a numeric datetime argument containing a number of seconds since January 1, 1900, and a datetime format string. It returns the date represented by the first argument, in the format corresponding to the second argument. $Sir_NS2Date accepts an optional error control string and returns the null string if an error is detected. | The <var>$Sir_NS2Date</var> function expects a numeric datetime argument containing a number of seconds since January 1, 1900, and a datetime format string. It returns the date represented by the first argument, in the format corresponding to the second argument. <var>$Sir_NS2Date</var> accepts an optional error control string and returns the null string if an error is detected. | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><section begin="syntax" /> %dat = $Sir_NS2Date(datn, fmt, errctl) | <p class="syntax"><section begin="syntax" /> %dat = $Sir_NS2Date(datn, fmt, errctl) | ||
<section end="syntax" /></p> | <section end="syntax" /></p> | ||
===Syntax terms=== | |||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>datn</th> | <tr><th>datn</th> | ||
<td> | <td>Datetime number containing a signed number of seconds since January 1, 1900.</td></tr> | ||
<tr><th>fmt</th> | <tr><th>fmt</th> | ||
<td> | <td>Datetime format string. Refer to [[Datetime string formats|"Datetime string formats"]] for an explanation of valid datetime formats and valid datetime values.</td></tr> | ||
<tr><th>errctl</th> | <tr><th>errctl</th> | ||
<td> | <td>Optional error control string; refer to [[Datetime string formats#Datetime error handling|"Datetime error handling"]].</td></tr> | ||
<tr><th>%dat</th> | <tr><th>%dat</th> | ||
<td> | <td>Set to the datetime value string, using format specified by <var class="term">fmt/var>, corresponding to <var class="term">datn</var>, unless an error is detected. | ||
</td></tr> | </td></tr> | ||
</table> | </table> | ||
==Example== | |||
<p class="code"> %X = $Sir_Date2NS('8407301230', 'YYMMDDHHMI') | The following fragment prints the string <tt>07/31/84</tt>: | ||
<p class="code">%X = $Sir_Date2NS('8407301230', 'YYMMDDHHMI') | |||
* Add 15 hours: | |||
%X = %X + 60 * 60 * 15 | |||
PRINT $Sir_NS2Date(%X, 'MM/DD/YY') | |||
</p> | </p> | ||
==Usage notes== | |||
<ul> | <ul> | ||
<li> | <li>The inverse of this $function is <var>[[$Sir_Date2NS]]</var>. | ||
<li> | <li><var>$Sir_NS2Date</var> returns a null string in the following cases: | ||
<ul> | |||
<li><var class="term">fmt</var> is not a valid datetime format. | |||
<li><var class="term">datn</var> out of range. | |||
</ul> | |||
</ul> | </ul> | ||
<ul class="smallAndTightList"> | <ul class="smallAndTightList"> |
Revision as of 21:30, 8 February 2012
Convert datetime number of seconds to string
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Sir_NS2Date function.
The $Sir_NS2Date function expects a numeric datetime argument containing a number of seconds since January 1, 1900, and a datetime format string. It returns the date represented by the first argument, in the format corresponding to the second argument. $Sir_NS2Date accepts an optional error control string and returns the null string if an error is detected.
Syntax
<section begin="syntax" /> %dat = $Sir_NS2Date(datn, fmt, errctl) <section end="syntax" />
Syntax terms
datn | Datetime number containing a signed number of seconds since January 1, 1900. |
---|---|
fmt | Datetime format string. Refer to "Datetime string formats" for an explanation of valid datetime formats and valid datetime values. |
errctl | Optional error control string; refer to "Datetime error handling". |
%dat | Set to the datetime value string, using format specified by fmt/var>, corresponding to datn, unless an error is detected. |
Example
The following fragment prints the string 07/31/84:
%X = $Sir_Date2NS('8407301230', 'YYMMDDHHMI') * Add 15 hours: %X = %X + 60 * 60 * 15 PRINT $Sir_NS2Date(%X, 'MM/DD/YY')
Usage notes
- The inverse of this $function is $Sir_Date2NS.
- $Sir_NS2Date returns a null string in the following cases:
- fmt is not a valid datetime format.
- datn out of range.