home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / cee / y2kdatm.cbl < prev   
Text File  |  1997-03-20  |  5KB  |  117 lines

  1. CBL LIB,APOST
  2.       ****************************************************
  3.       *                                                  *
  4.       *  Licensed Materials - Property of IBM.           *
  5.       *                                                  *
  6.       *  IBM VisualAge for COBOL: 5639-B92               *
  7.       *  (C) Copyright IBM Corp. 1983, 1997              *
  8.       *  All rights reserved                             *
  9.       *                                                  *
  10.       *  US Government Users Restricted Rights - Use,    *
  11.       *  duplication or disclosure restricted by GSA     *
  12.       *  ADP Schedule Contract with IBM Corp.            *
  13.       *                                                  *
  14.       ****************************************************
  15.       **                                                **
  16.       ** Function: CEEDATM - convert seconds to         **
  17.       **                     character timestamp        **
  18.       **                                                **
  19.       ** In this example, a call is made to CEEDATM     **
  20.       ** to convert a date represented in Lilian        **
  21.       ** seconds (the number of seconds since           **
  22.       ** 00:00:00 14 October 1582) to a character       **
  23.       ** format (such as 06/02/88 10:23:45). The        **
  24.       ** result is displayed.                           **
  25.       **                                                **
  26.       ****************************************************
  27.        IDENTIFICATION DIVISION.
  28.        PROGRAM-ID. CBLDATM.
  29.        DATA DIVISION.
  30.        WORKING-STORAGE SECTION.
  31.        01  DEST          PIC S9(9) BINARY VALUE 2.
  32.        01  SECONDS                 COMP-2.
  33.        01  IN-DATE.
  34.            02  Vstring-length      PIC S9(4) BINARY.
  35.            02  Vstring-text.
  36.                03  Vstring-char    PIC X
  37.                            OCCURS 0 TO 256 TIMES
  38.                            DEPENDING ON Vstring-length
  39.                                of IN-DATE.
  40.        01  PICSTR.
  41.            02  Vstring-length      PIC S9(4) BINARY.
  42.            02  Vstring-text.
  43.                03  Vstring-char    PIC X
  44.                            OCCURS 0 TO 256 TIMES
  45.                            DEPENDING ON Vstring-length
  46.                               of PICSTR.
  47.        01  TIMESTP                 PIC X(80).
  48.        01  FC.
  49.            02  Condition-Token-Value.
  50.            COPY  CEEIGZCT.
  51.                03  Case-1-Condition-ID.
  52.                    04  Severity    PIC S9(4) COMP-5.
  53.                    04  Msg-No      PIC S9(4) COMP-5.
  54.                03  Case-2-Condition-ID
  55.                          REDEFINES Case-1-Condition-ID.
  56.                    04  Class-Code  PIC S9(4) COMP-5.
  57.                    04  Cause-Code  PIC S9(4) COMP-5.
  58.                03  Case-Sev-Ctl    PIC X.
  59.                03  Facility-ID     PIC XXX.
  60.            02  I-S-Info            PIC S9(9) COMP-5.
  61.  
  62.        PROCEDURE DIVISION.
  63.        PARA-CBLDATM.
  64.       *************************************************
  65.       ** Call CEESECS to convert timestamp of 6/2/88 **
  66.       **     at 10:23:45 AM to Lilian representation **
  67.       *************************************************
  68.            MOVE 20 TO Vstring-length of IN-DATE.
  69.            MOVE '06/02/88 10:23:45 AM'
  70.                TO Vstring-text of IN-DATE.
  71.            MOVE 20 TO Vstring-length of PICSTR.
  72.            MOVE 'MM/DD/YY HH:MI:SS AP'
  73.                TO Vstring-text of PICSTR.
  74.            CALL 'CEESECS' USING IN-DATE, PICSTR,
  75.                                 SECONDS, FC.
  76.  
  77.       *************************************************
  78.       ** If CEESECS runs successfully, display result**
  79.       *************************************************
  80.            IF  CEE000 of FC  THEN
  81.                DISPLAY Vstring-text of IN-DATE
  82.                    ' is Lilian second:  ' SECONDS
  83.            ELSE
  84.                DISPLAY 'CEESECS failed with msg '
  85.                    Msg-No of FC UPON CONSOLE
  86.                STOP RUN
  87.            END-IF.
  88.  
  89.  
  90.       *************************************************
  91.       ** Specify desired format of the output.       **
  92.       *************************************************
  93.            MOVE 35 TO Vstring-length OF PICSTR.
  94.            MOVE 'ZD Mmmmmmmmmmmmmmz YYYY at HH:MI:SS'
  95.                    TO Vstring-text OF PICSTR.
  96.  
  97.       *************************************************
  98.       ** Call CEEDATM to convert Lilian seconds to   **
  99.       **     a character timestamp                   **
  100.       *************************************************
  101.            CALL 'CEEDATM' USING SECONDS, PICSTR,
  102.                                 TIMESTP, FC.
  103.  
  104.       *************************************************
  105.       ** If CEEDATM runs successfully, display result**
  106.       *************************************************
  107.            IF CEE000 of FC  THEN
  108.                DISPLAY 'Input seconds of ' SECONDS
  109.                    ' corresponds to: ' TIMESTP
  110.            ELSE
  111.                DISPLAY 'CEEDATM failed with msg '
  112.                    Msg-No of FC UPON CONSOLE
  113.                STOP RUN
  114.            END-IF.
  115.  
  116.            GOBACK.
  117.