HP 3000 Manuals

CURRENT-DATE Function [ HP COBOL II/XL Reference Manual ] MPE/iX 5.0 Documentation


HP COBOL II/XL Reference Manual

CURRENT-DATE Function 

The CURRENT-DATE function returns the calendar date, time of day, and the
difference between the local time and Universal Coordinated Time (UTC),
or Greenwich Mean Time.  To get the correct time differential, you need
to set the environment variable TZ to your local time zone.  See below
for more information.  The function type is alphanumeric.

This function is different from the CURRENT-DATE special register word
(described in Chapter 3 ).  One difference is that the CURRENT-DATE
function provides a four-digit year.

Syntax 

     FUNCTION CURRENT-DATE 

Return Values 

This function returns a 21-character alphanumeric string with each
character position defined as follows:

 Character                            Contents 
 Positions 

    1-4      Four numeric digits of the year in the Gregorian calendar.

    5-6      Two numeric digits of the month of the year, in the range
             01 through 12.

    7-8      Two numeric digits of the day of the month, in the range 01
             through 31.

    9-10     Two numeric digits of the hours past midnight, in the range
             00 through 23.

   11-12     Two numeric digits of the minutes past the hour, in the
             range 00 through 59.

   13-14     Two numeric digits of the seconds past the minute, in the
             range 00 through 59.

   15-16     Two numeric digits of the hundredths of a second past the
             second, in the range 00 through 99.  The value 00 is
             returned because your system cannot provide the fractional
             part of a second.

     17      One of the following:

             Value    When Returned   

               -      Returned if the local time in the previous
                      character positions is behind Greenwich Mean Time.

              +       Returned if the local time indicated is the same
                      or is ahead of Greenwich Mean Time.

              0       Returned on non-MPE XL systems that do not have
                      the facility to provide the local time
                      differential factor.

          Table 10-6.  (cont.) 

 Character                            Contents 
 Positions 

   18-19     Depending on the value of character position 17, one of the
             following:

             Position 17 Contents   

                 -       Two numeric digits in the range 00 through 12
                         indicating the number of hours that the
                         reported time is behind Greenwich Mean Time.

                +        Two numeric digits in the range 00 through 13
                         indicating the number of hours that the
                         reported time is ahead of Greenwich Mean Time.

                0        The value 00 is returned.

   20-21     Depending on the value of character position 17, one of the
             following:

             Position 17 Contents   

                 -       Two numeric digits in the range 00 through 59
                         indicating the number of additional minutes
                         that the reported time is behind of Greenwich
                         Mean Time.

                +        Two numeric digits in the range 00 through 59
                         indicating the number of additional minutes
                         that the reported time is ahead of Greenwich
                         Mean Time.

                0        The value 00 is returned.

Setting the TZ Environment Variable 

To get the correct difference between local time and Greenwich Mean Time,
you must set the environment variable TZ to your local time zone.  To set
TZ, use the MPE XL SETVAR command.  For example, the following command
sets the time zone to Central Standard Time and Central Daylight Time,
which would be correct for Chicago, Illinois:

     :SETVAR TZ 'CST6CDT'

The following table lists some time zones.  Check your local time zone to
be sure you use the correct one. 

          Table 10-7.  Time Zones and TZ Environment Variable Values 

----------------------------------------------------------------------------------------
|            |                                    |                                    |
|  TZ Value  |             Time Zone              |          Geographic Area           |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| HST10      | Hawaiian Standard Time, Hawaiian   | Unites States:  Hawaii.            |
|            | Daylight Time.                     |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| AST10ADT   | Aleutian Standard Time, Aleutian   | United States:  Alaska (parts).    |
|            | Daylight Time.                     |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| YST9YDT    | Yukon Standard Time, Yukon         | United States:  Alaska (parts).    |
|            | Daylight Time.                     |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| PST8PDT    | Pacific Standard Time, Pacific     | Canada:  British Columbia.  United |
|            | Daylight Time.                     | States:  California, Idaho         |
|            |                                    | (parts), Nevada, Oregon (parts),   |
|            |                                    | Washington.                        |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| MST7MDT    | Mountain Standard Time, Mountain   | Canada:  Alberta, Saskatchewan     |
|            | Daylight Time.                     | (parts).  United States:           |
|            |                                    | Colorado, Idaho (parts), Kansas    |
|            |                                    | (parts), Montana, Nebraska         |
|            |                                    | (parts), New Mexico, North Dakota  |
|            |                                    | (parts), Oregon (parts), South     |
|            |                                    | Dakota (parts), Texas (parts),     |
|            |                                    | Utah, Wyoming.                     |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| MST7       | Mountain Standard Time.            | United States:  Arizona.           |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| CST6CDT    | Central Standard Time, Central     | Canada:  Manitoba, Ontario         |
|            | Daylight Time.                     | (parts), Saskatchewan (parts).     |
|            |                                    | United States:  Alabama, Arkansas, |
|            |                                    | Florida (parts), Illinois, Iowa,   |
|            |                                    | Kansas, Kentucky (parts),          |
|            |                                    | Louisiana, Michigan (parts),       |
|            |                                    | Minnesota, Mississippi, Missouri,  |
|            |                                    | Nebraska, North Dakota, Oklahoma,  |
|            |                                    | South Dakota, Tennessee (parts),   |
|            |                                    | Texas, Wisconsin.                  |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| EST6CDT    | Eastern Standard Time, Central     | United States:  Indiana (most).    |
|            | Daylight Time.                     |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| EST5EDT    | Eastern Standard Time, Eastern     | Canada:  Ontaria (parts), Quebec   |
|            | Daylight Time.                     | (parts).  United States:           |
|            |                                    | Connecticut, Delaware, District of |
|            |                                    | Columbia, Florida, Georgia,        |
|            |                                    | Kentucky, Maine, Maryland,         |
|            |                                    | Massachusetts, Michigan, New       |
|            |                                    | Hampshire, New Jersey, New York,   |
|            |                                    | North Carolina, Ohio,              |
|            |                                    | Pennsylvania, Rhode Island, South  |
|            |                                    | Carolina, Tennessee (parts),       |
|            |                                    | Vermont, Virginia, West Virginia.  |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| AST4ADT    | Atlantic Standard Time, Atlantic   | Canada:  Newfoundland (parts),     |
|            | Daylight Time.                     | Nova Scotia, Prince Edward Island, |
|            |                                    | Quebec (parts).                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| NST3:30NDT | Newfoundland Standard Time,        | Canada:  Newfoundland (parts).     |
|            | Newfoundland Daylight Time.        |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| WET0WETDST | Western European Time, Western     | Great Britain, Ireland.            |
|            | European Time Daylight Savings     |                                    |
|            | Time.                              |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| PWT0PST    | Portuguese Winter Time, Portuguese |                                    |
|            | Summer Time.                       |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| MEZ-1MESZ  | Mitteleuropaeische Zeit,           |                                    |
|            | Mitteleuropaeische Sommerzeit.     |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| MET-       | Middle European Time, Middle       | Belgium, Lexembourg, Netherlands,  |
| 1METDST    | European Time Daylight Savings     | Denmark, Norway, Austria, Poland,  |
|            | Time.                              | Czechoslovakia, Sweden,            |
|            |                                    | Switzerland, Germany, France,      |
|            |                                    | Spain, Hungary, Italy, Yugoslavia. |
|            |                                    |                                    |
----------------------------------------------------------------------------------------

          Table 10-7.  Time Zones and TZ Environment Variable Values (cont.) 

----------------------------------------------------------------------------------------
|            |                                    |                                    |
|  TZ Value  |             Time Zone              |          Geographic Area           |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| SAST-2SADT | South Africa Standard Time, South  | South Africa.                      |
|            | Africa Daylight Time.              |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| JST-9      | Japan Standard Time.               | Japan.                             |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| WST-8:00   | Australian Western Standard Time.  | Australia:  Western Australia.     |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| CST-9:30   | Australian Central Standard Time.  | Australia:  Northern Territory.    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| CST-       | Australian Central Standard Time,  | Australia:  South Australia.       |
| 9:30CDT    | Australian Central Daylight Time.  |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| EST-10     | Australian Eastern Standard Time.  | Australia:  Queensland.            |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| EST-10EDT  | Australian Eastern Standard Time,  | Australia:  New South Wales,       |
|            | Australian Eastern Daylight Time.  | Tasmania, Victoria.                |
|            |                                    |                                    |
----------------------------------------------------------------------------------------
|            |                                    |                                    |
| NZST-      | New Zealand Standard Time, New     | New Zealand.                       |
| 12NZDT     | Zealand Daylight Time.             |                                    |
|            |                                    |                                    |
----------------------------------------------------------------------------------------

If TZ is not set, CURRENT-DATE assumes Eastern Standard Time (EST5EDT).

The time differential is automatically adjusted for daylight savings time
according to the values in the time and zone adjustment table (the file
TZTAB.LIB.SYS).


NOTE Make sure your system administrator has correctly set the hardware clock. The hardware clock must be set to Greenwich Mean Time (Universal Coordinated Time or UTC) for CURRENT-DATE to return the correct local date and time. See the System Startup, Configuration, and Shutdown Reference Manual for how to set the hardware clock with the CLKUTIL utility.
Example 01 FULL-CURRENT-DATE. 05 C-DATE. 10 C-YEAR PIC 9(4). 10 C-MONTH PIC 99. 10 C-DAY PIC 99. 05 C-TIME. 10 C-HOUR PIC 99. 10 C-MINUTES PIC 99. 10 C-SECONDS PIC 99. 10 C-SEC-HUND PIC 99. 05 C-TIME-DIFF. 10 C-GMT-DIR PIC X. 10 C-HOUR PIC 99. 10 C-MINUTES PIC 99. : MOVE FUNCTION CURRENT-DATE TO FULL-CURRENT-DATE. DISPLAY "Full date is: ", FULL-CURRENT-DATE. DISPLAY "Year is: ", C-YEAR. DISPLAY "Month is: ", C-MONTH. DISPLAY "Day is: ", C-DAY. DISPLAY "Hour is: ", C-HOUR OF C-TIME. DISPLAY "Minute is: ", C-MINUTES OF C-TIME. DISPLAY "Second is: ", C-SECONDS. DISPLAY "Hundredths of seconds is: ", C-SEC-HUND. DISPLAY "Difference from GMT is: ", C-GMT-DIR. DISPLAY "Hours from GMT is: ", C-HOUR OF C-TIME-DIFF. DISPLAY "Minutes from GMT is: ", C-MINUTES OF C-TIME-DIFF. With TZ set to PST8PDT, the above example displays the following: Full date is: 1991022017152900-0800 Year is: 1991 Month is: 02 Day is: 20 Hour is: 17 Minute is: 15 Second is: 29 Hundredths of seconds is: 00 Difference from GMT is: - Hours from GMT is: 08 Minutes from GMT is: 00


MPE/iX 5.0 Documentation