Overview of $Date functions: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 2: Line 2:
All $Date functions &mdash; <var>$Date</var>, <var>$DATEJ</var>, <var>$DATEP</var> &mdash; accept two input arguments.</p>
All $Date functions &mdash; <var>$Date</var>, <var>$DATEJ</var>, <var>$DATEP</var> &mdash; accept two input arguments.</p>


====Syntax====
==Syntax==
<p class="syntax">$Date(<span class="term">year-format</span>, <span class="term">fill-character</span>)
<p class="syntax">$Date(<span class="term">year-format</span>, <span class="term">fill-character</span>)
</p>
</p>
Line 73: Line 73:
</ul>
</ul>


====Usage====
==Usage==
<p>
<p>
$DateChg, $DateChk, $DateCnv, and $DateDif recognize a format of CYY as representing the century-year format as returned from the $Date function. Conversion to and from the CYY format is fully supported. </p>
$DateChg, $DateChk, $DateCnv, and $DateDif recognize a format of CYY as representing the century-year format as returned from the $Date function. Conversion to and from the CYY format is fully supported. </p>
Line 79: Line 79:
In addition, if <code>CUSTOM=1</code> is added to the User 0 CCAIN stream or set later using the RESET command, the following occurs: If a CYY date format is specified for conversion and only a YY input is supplied, the conversion is successfully completed by using the <var>[[CENTSPLT parameter|CENTSPLT]]</var> and <var>[[BASECENT parameter|BASECENT]]</var> parameters.  </p>
In addition, if <code>CUSTOM=1</code> is added to the User 0 CCAIN stream or set later using the RESET command, the following occurs: If a CYY date format is specified for conversion and only a YY input is supplied, the conversion is successfully completed by using the <var>[[CENTSPLT parameter|CENTSPLT]]</var> and <var>[[BASECENT parameter|BASECENT]]</var> parameters.  </p>


====Examples====
==Examples==
<ul>
<ul>
<li>IF CUSTOM=1, BASECENT=19, and CENTSPLT=95, then:</li>
<li>IF CUSTOM=1, BASECENT=19, and CENTSPLT=95, then:</li>
Line 146: Line 146:
</ul>
</ul>


====Julian dates====
==Julian dates==
<p>The Julian date is a 4-byte, packed decimal formatted as follows:</p>
<p>The Julian date is a 4-byte, packed decimal formatted as follows:</p>
<p class="code">0CYYDDDF  
<p class="code">0CYYDDDF  
Line 168: Line 168:
</ul>
</ul>


====Routines available for user-written date $functions====
==Routines available for user-written date $functions==
<p>
<p>
CCALL entry points have been added: DATE, DATE3, and DATE4. All routines must be called with T1 pointing to a 26-byte answer area. [[Contacting Rocket Software Technical Support|Technical Support]] recommends that you allocate the answer area using the VARS=(name, len) pushdown list variable of the ENTER macro. (See [[Customizing function and translation tables]] for more information on the ENTER macro.) </p>
CCALL entry points have been added: DATE, DATE3, and DATE4. All routines must be called with T1 pointing to a 26-byte answer area. [[Contacting Rocket Software Technical Support|Technical Support]] recommends that you allocate the answer area using the VARS=(name, len) pushdown list variable of the ENTER macro. (See [[Customizing function and translation tables]] for more information on the ENTER macro.) </p>

Revision as of 18:42, 18 August 2014

All $Date functions — $Date, $DATEJ, $DATEP — accept two input arguments.

Syntax

$Date(year-format, fill-character)

Where::

  • The year-format argument controls the format of the year based on the following input values:
  • year-format input Return format Example: Year 2013 displayed as...
    0 YY 13
    1 YYYY 2013
    2 CYY 113 (The first digit represents the century since 1900)

    CYY represents the century-year format. The first digit represents the century since 1900. The CYY format can be manipulated using the CUSTOM parameter.

  • The fill-character argument indicates a 1-byte fill character to place between the date components, as in the following examples:
    Code example Return format Example: July 11, 2013
    $date(2,' ') 'CYY MM DD' 113 07 11
    $date(0,'Z') 'YYzMMzDD' 13z07z11
    $DATEJ(1,'-') 'YYYY-DDD' 2013-192
    $DATEJ(1,) 'YYYYDDD' 2013192

Usage

$DateChg, $DateChk, $DateCnv, and $DateDif recognize a format of CYY as representing the century-year format as returned from the $Date function. Conversion to and from the CYY format is fully supported.

In addition, if CUSTOM=1 is added to the User 0 CCAIN stream or set later using the RESET command, the following occurs: If a CYY date format is specified for conversion and only a YY input is supplied, the conversion is successfully completed by using the CENTSPLT and BASECENT parameters.

Examples

  • IF CUSTOM=1, BASECENT=19, and CENTSPLT=95, then:
  • Print command Results
    PRINT $DATECNV('CYYDDD','YYYYMMDD','96001') 19960101
    PRINT $DATECNV('CYYDDD','YYYYMMDD','196001') 20960101
    PRINT $DATECNV('CYYDDD','YYYYMMDD','95001') 19950101
    PRINT $DATECNV('CYYDDD','YYYYMMDD','095001') 19950101
  • If CUSTOM=1 is omitted, BASECENT=19, and CENTSPLT=95, then:
  • Print command Results
    PRINT $DATECNV('CYYDDD','YYYYMMDD','96001') ******
    PRINT $DATECNV('CYYDDD','YYYYMMDD','196001') 20960101
    PRINT $DATECNV('CYYDDD','YYYYMMDD','95001') ******
    PRINT $DATECNV('CYYDDD','YYYYMMDD','095001') 19950101
  • If CUSTOM=2 is added to the User 0 CCAIN stream or set later using the RESET command, the following occurs: If a CYY-format is specified for output conversion and the C indicator is zero, then C is eliminated. This is true for all $Date function calls. For example:

    If CUSTOM=2, then: PRINT $DATEJ(2) prints 97.001.

    But if CUSTOM=2 is omitted, then PRINT $DATEJ(2) prints 097.001.

Julian dates

The Julian date is a 4-byte, packed decimal formatted as follows:

0CYYDDDF

Where:

  • 0 is a reserved filler.
  • C represents the century since 1900. For example:

    C=0 represents years 1900-1999.

    C=1 represents years 2000-2099.

  • YY is 2-byte year.
  • DDD is 3-byte day.
  • F is positive-sign nibble for packed decimal

Routines available for user-written date $functions

CCALL entry points have been added: DATE, DATE3, and DATE4. All routines must be called with T1 pointing to a 26-byte answer area. Technical Support recommends that you allocate the answer area using the VARS=(name, len) pushdown list variable of the ENTER macro. (See Customizing function and translation tables for more information on the ENTER macro.)

The current date and time are stored in the area with this format:

Code entry point Format used for storing...
DATE YY.DDD  MON DD  HH.MM.SS
DATE3 CYY.DDD  MON DD  HH.MM.SS
DATE4 YYYY.DDD  MON DD  HH.MM.SS

All registers are returned intact with the exception of the DATE and DATE4 calls. The DATE and DATE4 calls change only the T4 register, returning a number representing the current month (1-12).

DATE returns 24 bytes, DATE3 returns 25 bytes, and DATE4 returns 26 bytes.

Note: There are two spaces before and after MON DD.