HPlogo MPE/iX Intrinsics Reference Manual > Chapter 7 Command Definitions (HP32208-HPLOACNMPROC)

HPDATEFORMAT

MPE documents

Complete PDF
Table of Contents
Index

Edition 7 E0701 ♥
Edition 7 E0300
Edition 6 E0195

NM callable only.

You can use this routine to format the dates that can be combinations of display formats as explained below. Many of these elements are taken from ALLBASE/SQL date formats.

You can convert dates in the "Supported Date Formats" to a display string of your choice (with restrictions).

Syntax



                I32V      *          CA          CA       I32
  HPDATEFORMAT (datecode, inputdate, formatspec, fmtdate, fmtdatlen,
                I32     I32V
                status, cutoff);

Parameters


datecode

is a 32 bit signed integer by value

The value should be one of the date type codes listed in the table, "Supported Date Formats" found with the HPDATECONVERT intrinsic.

inputdate

is the input date.

The interpretation depends on the value of datecode

See the table, "Supported Date Formats," for the supported date codes and their layouts.

formatspec

is a character array (required).

This should be a NULL terminated string. The HPDATEFORMAT intrinsic will accept the following format strings:


  {Format Element}[{Punctuation} ...]

Valid Parameters for Format Element

Table 7-9 Format Specification Strings

String Definition
CC Century (01 to 99)
YYYYYear (0001 to 9999)
YY Year of century (00 to 99) with leading zeros suppressed (0 to 99)
Q Calendar quarter of the year (1 to 4)
MM Month of the year (01 to 12)
ZMM Month of the year with leading zeros suppressed (1 to 12)
DD Day of the month (01 to 31)
ZDD Day of the month with leading zero suppressed (1 to 31)
DDD Day of the year (001 to 366).
ZDDDDDD with leading zeros suppressed (1 to 366)
D Day of the week (1 to 7 where Sunday is 1, Monday is 2, ...)
WW Week of the year (01 to 53)
ZWW Week of the year with leading zero suppressed (1 to 53)
Mon Month of the year in ASCII format (Jan, Feb, ...)
Day Day of the week in ASCII format (Sun, Mon, ...)
MON Month of the year in ASCII (uppercase) format (JAN, FEB, ...)
DAY Day of the week in ASCII (uppercase) format (SUN, MON, ...)

Table 7-10 Valid Characters for Punctuation

Character Definition
-Hyphen
/Slash
.Dot
' 'Blank
,Comma
''Null

Thus, YYYY.MON.DAY, YY/MM/DD, DDMONYY, and DD-ZMM-YYYY are valid date formts. For example, "31 jan 1997" when formatted through DD-ZMM-YYYY results in "31-1-1997," formatted through YYYY/MM/DAY results in "1997.JAN.FRI," while YYYYMMDD results in "19970131".


NOTE: Mixing the NULL punctuation character with other punctuation characters is not allowed. Thus, YYYY/MM/DD is a valid format, while YYYYMM/DD is not.

fmtdate

is a character array (required).

This array size should be at least that of formatspec. On return, it will contain the date formatted as per the formatspec.

If an invalid date is passed, on return from the intrinsic its contents will be "UNKNOWN." For the "HP Standard Formats," if special values in the table, "Special Date Values," are passed for date parameter, on return from the intrinsic, the value of the string will be appropriately initialized. For example, for the date type 18, the initialized values for different special date values are as follows:

Date ValueReturned Contents
00000000"UNKNOWN"
00000101"INVALID"
00000102"NEVER"
00000103"NEEDED"
00000104"EXPIRED"
00000105"ILLEGAL"

If the character array passed does not have enough space to hold the special values or the formatted date, the behavior is undefined.

fmtdatelen

is a 32 bit integer by reference (required).

On input, it is the length of the formatspec parameter. On return, it represents the number of characters HPDATEFORMAT placed into fmtdate.

status

is the HPE_STATUS parameter

through which the error codes are returned. A value of 0 indicates no errors and no warnings.

cutoff

is a 32 bit signed integer by value (optional).

This is used in validating and converting the two-digit years to four digit ones before computing the difference. (See HPDATECONVERT documentation for more information.)

Related Information


IntrinsicsHPCALENDAR, HPDATECONVERT, HPDATEDIFF, HPDATEOFFSET, HPDATEVALIDATE, HPFMTCALENDAR
Manuals




HPDATEDIFF


HPDATEOFFSET