Date Processing
Validate, Format and Convert
  Table of Contents  v-16.01.01 - cbldat01.htm 
  Introduction
  Programming Objectives
  Programming Input and Output
  Programming Requirements
  Programming Overview
  The CALL Interface
  Sample CMD Files
  Run the Date Validation Job
  Create a Date Card File
  Sample JCL Members
  Run the Date Validation Job
  Create a Date Card File
  The COBOL Programs
  The Primary Program
  The Date Validation Routine
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

This suite of programs provides an example of various routines that edit, validate, format or convert dates. Two COBOL programs are provided. The first program is a demonstration program that reads a file containing "date-card" records and calls the second COBOL program that actually does the date validation, formatting and conversion.

Both COBOL programs are written using the OS390 dialect and also work with Enterprise COBOL. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows. A Windows Command (.CMD) file is provided to run the job on a PC with Micro Focus Net Express. This program may serve as a tutorial for new programmers and as a reference for experienced programmers.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Programming Objectives

The following is a list of the functions provided in this example.

1 Accept Gregorian date as input.
2 Validate the month for 1-12 and create text string (i.e. month 7 is July).
3 Determine if the year is a leap year.
4 Validate the day for 1-30, 1-31, 1-28 or 1-29 based on month and leap year.
5 Create a text string for the date (i.e. 2002/01/01 is January 1, 2002)
6 Create a ccyyddd format for the date (i.e. 2002/04/01 is 2002092)
7 Calculate days remaining in the year.
8 Provide an edited Gregorian Date (I.e. 20020915 could be 2002-09-15)
  Programming Objectives for the Data Validation Example

Table of Contents Previous Section Next Section Programming Input and Output

The following is an example of the contents of the input or date-card file (SYSUT1).

DATECARD 19761124
DATECARD 20000401
DATECARD 20001315
DATECARD 2001/01/01
DATECARD 1999-01-32
DATECARD 1999-02/15
DATECARD 1968-07/31
DATECARD 2001/06/31
DATECARD 1998/9/15
DATECARD 2004/10/7
DATECARD 1600/04/01
DATECARD 1700/05/01

The following is an example of the output file (SYSUT2) based on the preceding date-card file.

********************************************************************************
DATECARD 19761124
Display the Date Edit Results
Gregorian Date .............. 19761124
Edited Gregorian Date ....... 1976-11-24
Text for the Date............ November 24, 1976
Julian Date ................. 1976329
Days remaining in the year .. 037
Leap Year Flag (Y or N) ..... Y
Days in the Month ........... 30
Text for the Month .......... November
********************************************************************************
DATECARD 20000401
Display the Date Edit Results
Gregorian Date .............. 20000401
Edited Gregorian Date ....... 2000-04-01
Text for the Date............ April 1, 2000
Julian Date ................. 2000092
Days remaining in the year .. 274
Leap Year Flag (Y or N) ..... Y
Days in the Month ........... 30
Text for the Month .......... April
********************************************************************************
DATECARD 20001315
NOK for Date Value, MM not 1 through 12...
********************************************************************************
DATECARD 2001/01/01
Display the Date Edit Results
Gregorian Date .............. 20010101
Edited Gregorian Date ....... 2001-01-01
Text for the Date............ January 1, 2001
Julian Date ................. 2001001
Days remaining in the year .. 364
Leap Year Flag (Y or N) ..... N
Days in the Month ........... 31
Text for the Month .......... January
********************************************************************************
DATECARD 1999-01-32
NOK for Day Value, DD not within month range...
********************************************************************************
DATECARD 1999-02/15
Display the Date Edit Results
Gregorian Date .............. 19990215
Edited Gregorian Date ....... 1999-02-15
Text for the Date............ February 15, 1999
Julian Date ................. 1999046
Days remaining in the year .. 319
Leap Year Flag (Y or N) ..... N
Days in the Month ........... 28
Text for the Month .......... February
********************************************************************************
DATECARD 1968-07/31
Display the Date Edit Results
Gregorian Date .............. 19680731
Edited Gregorian Date ....... 1968-07-31
Text for the Date............ July 31, 1968
Julian Date ................. 1968213
Days remaining in the year .. 153
Leap Year Flag (Y or N) ..... Y
Days in the Month ........... 31
Text for the Month .......... July
********************************************************************************
DATECARD 2001/06/31
NOK for Day Value, DD not within month range...
********************************************************************************
DATECARD 1998/9/15
Display the Date Edit Results
Gregorian Date .............. 19980915
Edited Gregorian Date ....... 1998-09-15
Text for the Date............ September 15, 1998
Julian Date ................. 1998258
Days remaining in the year .. 107
Leap Year Flag (Y or N) ..... N
Days in the Month ........... 30
Text for the Month .......... September
********************************************************************************
DATECARD 2004/10/7
Display the Date Edit Results
Gregorian Date .............. 20041007
Edited Gregorian Date ....... 2004-10-07
Text for the Date............ October 7, 2004
Julian Date ................. 2004281
Days remaining in the year .. 085
Leap Year Flag (Y or N) ..... Y
Days in the Month ........... 31
Text for the Month .......... October
********************************************************************************
DATECARD 1600/04/01
Display the Date Edit Results
Gregorian Date .............. 16000401
Edited Gregorian Date ....... 1600-04-01
Text for the Date............ April 1, 1600
Julian Date ................. 1600092
Days remaining in the year .. 274
Leap Year Flag (Y or N) ..... Y
Days in the Month ........... 30
Text for the Month .......... April
********************************************************************************
DATECARD 1700/05/01
Display the Date Edit Results
Gregorian Date .............. 17000501
Edited Gregorian Date ....... 1700-05-01
Text for the Date............ May 1, 1700
Julian Date ................. 1700121
Days remaining in the year .. 244
Leap Year Flag (Y or N) ..... N
Days in the Month ........... 31
Text for the Month .......... May

Table of Contents Previous Section Next Section Programming Requirements

This suite of samples programs will run on the following platforms.

1 Executes on Windows/XP, Windows/7 and/or Windows Server using Micro Focus technologies and the CMD files provided.
2 May be ported to run on the Linux and UNIX platforms supported by Micro Focus COBOL.
3 Executes on an IBM Mainframe with ZOS or Windows, Linux or UNIX using Micro Focus technologies and the JCL members provided.
  Program Requirements for the Data Validation Example

Table of Contents Previous Section Next Section Programming Overview

The following diagram is an overview of how the demonstration program fits into the example. The demonstration program will read the date card file (SYSUT1), call the date routine and write the results to the output file (SYSUT2).

           
Entry Point
ZOS
Entry Point
Windows
   
   
CBLDATJ1
jcl
CBLDATE1
cmd
Start the date processing example
   
   
IEFBR14
Utility
IF Exist
statement
Delete previously created Date Info file
   
   
 
 
   
   
 
 
   
   
SYSUT1
rseq
 
 
CBLDATC1
cbl
   
   
SYSUT2
rseq
Read the date cards (SYSUT1), call the date routine then write the results to a file (SYSUT2.
   
   
   
   
   
SIMODATE
cbl
Validate, format and convert the date.
   
EOJ
End-Of-Job
 
Overview of the Sample date Validation Process

Table of Contents Previous Section Next Section The CALL Interface

The following is the syntax for calling the date routine (SIMODATE.CBL).

        call 'SIMODATE' using STD-SIMODATE

The callable date routine will accept a Gregorian date and provide a data structure in the following format. A copy file (PASSDATE.CPY) is provided with the following fields defined.

      *****************************************************************
      *     Data Structure or Pass Area used for calling SIMODATE.    *
      *****************************************************************
      *         Copyright (C) 1987-2019 SimoTime Technologies         *
      *                     All Rights Reserved                       *
      *****************************************************************
      *              Provided by SimoTime Technologies                *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************
      * STD-REQUEST          - This is an eight character data string
      *                        and should contain the following in
      *                        upper case.
      *                        EDITDATE, This keyword causes the date
      *                        routine (SIMODATE) to validate the date
      *                        and provide an edited text string plus
      *                        a julian date and more.
      *                        EDITJDAT, WIP
      *                        The calling program must provide the
      *                        above as a request. Otherwise, a non-
      *                        zero return code will be set in the
      *                        following result field. This data string
      *                        is not changed by the date routine.
      *
      * STD-RESPONSE         - This is a four byte binary data string
      *                        and is used by the conversion routine to
      *                        pass a return code. If the date request
      *                        is successful the value in this data
      *                        string will be zero.
      *
      * STD-MESSAGE-TEXT     - If a non-zero response occurs this field
      *                        will contain a short message.
      *
      * STD-GREGORIAN-4-EDIT - This is the input date field in
      *                        gregorian format that will be validated.
      *                        If the gregorian date does not pass the
      *                        editing process a message will be posted
      *                        in the STD-MESSAGE-TEXT field and a
      *                        non-zero value of 16 will be placed in
      *                        the STD-RESPONSE field. SimoDATE is
      *                        somewhat flexible in accepting and
      *                        reformatting a gregorian date. For
      *                        example, the following are acceptable
      *                        and will be reformatted into the
      *                        STD-GREGORIAN-4-EDIT field.
      *                        ccyymmdd   This is the preferred format.
      *                        ccyy-mm-dd Special characters may be
      *                                   used as separators.
      *                        ccyy-m-d   Single digit month and day
      *                                   values are acceptable when
      *                                   delimiter are used.
      *                        ccyy/m/dd  A mixing of single digit
      *                                   usage is accepted.
      *
      * STD-DEBUG-INFO       - This data string provides additional
      *                        debugging capability. This may be
      *                        helpful if changes are made to the date
      *                        routine.
      *
      * STD-LEAP-YEAR-YN     - This field is used to identify a leap
      *                        year. A "Y" indicates the input date is
      *                        a leap year. An "N" indicates the input
      *                        year is not a leap year.
      *
      * STD-MONTH-VERBAGE    - This field is used for the text of the
      *                        input month. For example, 1=January,
      *                        2=February, etc.
      *
      * STD-MM-DAYS          - This field is used for the number of
      *                        days in the input month.
      *
      * STD-GREGORIAN-DATE   - This field is used for the gregorian
      *                        date in ccyymmdd format (all numeric
      *                        values).
      *
      * STD-JULIAN-DATE      - This field is used for the julian date
      *                        in ccyyddd format.
      *
      * STD-DAYS-REMAINING   - The number of days remaining in the
      *                        year.
      *
      * STD-DATE-VERBAGE     - This field is used for the date in text
      *                        format. For example, 19991225 will
      *                        produce a text string of
      *                        December 25, 1999.
      *
      * STD-DATE-EDIT-BYTE   - This field contains the character that
      *                        will be used to edit and format the
      *                        gregorian date. For example, this field
      *                        may contain a space, a dash, a slash,
      *                        etc... and will be used as the delimiter
      *                        between the year, month and day.
      *
      * STD-DATE-EDITED      - This field if for the edited date using
      *                        the delimiter character from the
      *                        preceding field. For example, 19991225
      *                        will produce 1999/12/25 if the delimiter
      *                        character is a slash.
      * STD-DAY-OF-WEEK      - WIP, 1-7 is Sunday through Saturday.
      *****************************************************************
      *
       01  STD-SIMODATE.
           05  STD-REQUEST             pic X(8).
           05  STD-RESPONSE            pic 9(4).
           05  STD-MESSAGE-TEXT        pic X(68).
           05  STD-GREGORIAN-4-EDIT    pic X(10).
           05  STD-EDITED-INFO.
               10  STD-DEBUG-INFO      pic X(8).
               10  STD-LEAP-YEAR-YN    pic X.
               10  STD-MONTH-VERBAGE   pic X(10).
               10  STD-MM-DAYS         pic 99.
               10  STD-GREGORIAN-DATE  pic 9(8).
               10  STD-JULIAN-DATE     pic 9(7).
               10  STD-JULIAN-VALUE    redefines STD-JULIAN-DATE.
                   15  STD-JULIAN-CCYY pic 9(4).
                   15  STD-JULIAN-DAY  pic 9(3).
               10  STD-DAYS-REMAINING  pic 9(3).
               10  STD-DATE-VERBAGE    pic X(18).
               10  STD-DATE-EDIT-BYTE  pic X.
               10  STD-DATE-EDITED-14.
                   15  STD-DATE-DAY    pic X(3).
                   15  STD-DATE-DAY-2  pic X.
                   15  STD-DATE-EDITED pic X(10).
           05  STD-DAY-OF-WEEK.
               10  STD-DAY-OF-WEEK-NBR pic 9.
               10  STD-DAY-OF-WEEK-TXT pic X(10).
      ***  PASSDATE - End-of-Copy File - - - - - - - - - - - PASSDATE *
      *****************************************************************
      *

The following table is an overview of the data strings used in the pass area.

Field Name Description
STD-REQUEST This is an eight character data string and should contain the following in upper case.
EDITDATE This keyword causes the date routine (SIMODATE) to validate the date and provide and edited text string plus a julian date and more.
This calling program must provide one of the above as a request. Otherwise, a non-zero return code will be set in the following result field. This data string is not changed by the conversion routine.
STD-RESPONSE This is a four byte binary data string and is used by the conversion routine to pass a return code. If the conversion request is successful the value in this data string will be zero.
STD-MESSAGE-TEXT If a non-zero response occurs this field will contain a short message.
STD-GREGORIAN-4-EDIT

This is the input date field in gregorian format that will be vaidated. If the gregorian date does not pass the editing process a message will be posted in the STD-MESSAGE-TEXT field and a non-zero value of 16 will be placed in the STD-RESPONSE field. SimoDATE is somewhat flexible in accepting and reformatting a gregorian date. For example, the following are acceptable and will be reformatted into the STD-GREGORIAN-4-EDIT field.

ccyymmdd   This is the preferred format.
ccyy-mm-dd    Special characters may be used as separators.
ccyy-m-d   Single digit month and day values are acceptable when separators are used.
ccyy/m/dd   A mixing of single digit usage is accepted.
STD-DEBUG-INFO This data string provides additional debugging capability. This may be helpful if changes are made to the date routine..
STD-LEAP-YEAR-YN This field is used to identify a leap year. A "Y" indicates the input date is a leap year. An "N" indicates the input year is not a leap year.
STD-MONTH-VERBAGE This field is used for the text of the input month. For example, 1=January, 2=February, etc.
STD-MM-DAYS This field is used for the number of days in the input month.
STD-GREGORIAN-DATE This field is used for the gregorian date in ccyymmdd format (all numeric values).
STD-JULIAN-DATE This field is used for the julian date in ccyyddd format.
STD-DAYS-REMAINING The number of days remaining in the year.
STD-DATE-VERBAGE This field is used for the date in text format. For example, 19991225 will produce a text string of December 25, 1999.
STD-DATE-EDIT-BYTE This field contains the character that will be used to edit and format the gregorian date. For example, this field may contain a space, a dash, a slash, etc... and will be used as the delimiter between the year, month and day.
STD-DATE-EDITED This field if for the edited date using the delimiter character from the preceding field. For example, 19991225 will produce 1999/12/25 if the delimiter character is a slash.

Table of Contents Previous Section Next Section Sample CMD Files

This sample suite of programs has two CMD members. The first CMD member will execute the demonstration program. The second CMD member will create a Date Card file.

Table of Contents Previous Section Next Section Run the Date Validation Job

The following (CBLDATE1.cmd) is the CMD required to run the demonstration program on a Personal Computer with Micro Focus Studio or Server.

@echo OFF
rem  * *******************************************************************
rem  *               CBLDATE1.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Read a file of Date Cards, edit date, write output.
rem  * Author - SimoTime Technologies
rem  * Date   - January 24, 1996
rem  *
rem  * The job will read an 80-byte file that contains DATECARD
rem  * information. The job will also write a file containing the results
rem  * of the date edit functions..
rem  *
rem  * This set of programs will run on a mainframe under MVS or on a
rem  * Personal Computer with Windows and Micro Focus Net Express.
rem  *
rem  *    ************
rem  *    * CblDatE1 *
rem  *    ********cmd*
rem  *         *
rem  *         *
rem  *    ************     ************     ************
rem  *    *   run    ******* SIMONOTE ******* CONSOLE  *
rem  *    *******mifo*  *  ********cmd*  *  ************
rem  *         *        *                *
rem  *         *        *                *  ************
rem  *         *        *                ****  SYSLOG  *
rem  *         *        *                   ********txt*
rem  *         *        *
rem  *         *        **************************
rem  *         *                                 *
rem  *         *           ************     ************     ************
rem  *         *           *  SYSUT1  ******* CblDatC1 *******  SYSUT2  *
rem  *         *           ********txt*     ********cbl*     ********csv*
rem  *         *
rem  *    ************
rem  *    *   EOJ    *
rem  *    ************
rem  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables,
rem  *                Delete any previously created file...
rem  *
     set CmdName=CBLDATE1
     call ..\Env1BASE %CmdName%
rem  *
     call SimoNOTE "*******************************************************%CmdName%"
     call SimoNOTE "Starting CmdName %CmdName%"
:DeleteQSAM
     call SimoNOTE "Identify CmdStep DeleteQSAM"
     set SYSUT1=%BaseLib1%\DATA\Asc1\DATECARD.DAT
     set SYSUT2=%BaseLib1%\DATA\Wrk1\DATELIST.DAT
     if exist %SYSUT2% del %SYSUT2%
rem  *
rem  * *******************************************************************
rem  * Step   2   Edit input, create a new output file...
rem  *
:ExecuteDateRoutine
     call SimoNOTE "Identify CmdStep ExecuteDateRoutine"
     run CBLDATC1
     if exist %SYSUT2% call SimoNOTE "Produced DataSet %SYSUT2%"
rem  * *******************************************************************
rem  * Step   3 of 3  ConvertRecord Sequential File to ASCII/TEXT file...
rem  *
     call SimoNOTE "Identify JobStep Convert Line Sequential to Record Sequential"
     set GETRS080=%BaseLib1%\DATA\Wrk1\DATELIST.DAT
     set PUTLS080=%BaseLib1%\DATA\TXT1\DATELIST.TXT
     if exist %PUTLS080% del %PUTLS080%
     run CV80ARAL
     if exist %PUTLS080% call SimoNOTE "Produced DataSet %PUTLS080%"
     call SimoNOTE "Finished CmdName %CmdName%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Create a Date Card File

The following (CBLDATE2.cmd) is the CMD that may be used to create a date-card file.

@echo OFF
rem  * *******************************************************************
rem  *               CBLDATE2.CMD - a Windows Command File               *
rem  *         This program is provided by SimoTime Technologies         *
rem  *           (C) Copyright 1987-2019 All Rights Reserved             *
rem  *             Web Site URL:   http://www.simotime.com               *
rem  *                   e-mail:   helpdesk@simotime.com                 *
rem  * *******************************************************************
rem  *
rem  * Text   - Create a Sequential Data Set on disk using IEBGENER.
rem  * Author - SimoTime Technologies
rem  * Date   = January 24, 1996
rem  *
rem  * The first job step (DeleteQSAM) will delete any previously created
rem  * file. The second job step (CreateQSAM) will create a new file.
rem  *
rem  * This set of programs will run on a Personal Computer with Windows
rem  * and Micro Focus Net Express.
rem  *
rem  * ********************************************************************
rem  * Step   1 of 2  Set the global environment variables,
rem  *                Delete any previously created file...
rem  *
     set CmdName=CBLDATE2
     call ..\Env1BASE %CmdName%
rem  *
     call SimoNOTE "*******************************************************%CmdName%
     call SimoNOTE "Starting CmdName %CmdName%"
     call SimoNOTE "Identify CmdStep DeleteLSEQ"
     set DATECARD=%BaseLib1%\DATA\Txt1\DATECARD.TXT
     if exist %DATECARD% del %DATECARD%
rem  *
rem  * *******************************************************************
rem  * Step   2 of 3  Create and populate a new QSAM file...
rem  *
:CreateLSEQ
     call SimoNOTE "Identify CmdStep CreateQSAM"
rem  *....1....:....2....:....3....:....4....:....5....:....6....:....7....:....8
echo DATECARD 19761124                         >%DATECARD%
echo DATECARD 20000401                        >>%DATECARD%
echo DATECARD 20001315                        >>%DATECARD%
echo DATECARD 2001/01/01                      >>%DATECARD%
echo DATECARD 1999-01-32                      >>%DATECARD%
echo DATECARD 1999-02/15                      >>%DATECARD%
echo DATECARD 1968-07/31                      >>%DATECARD%
echo DATECARD 2001/06/31                      >>%DATECARD%
echo DATECARD 1998/9/15                       >>%DATECARD%
echo DATECARD 2004/10/7                       >>%DATECARD%
echo DATECARD 1600/04/01                      >>%DATECARD%
echo DATECARD 1700/05/01                      >>%DATECARD%
     if exist %DATECARD% call SimoNOTE "Produced DataSet %DATECARD%
     if not exist %DATECARD% set JobStatus=9001
     if not %JobStatus% == 0000 goto :EojNok
rem  * *******************************************************************
rem  * Step   3 of 3  ConvertASCII/TEXT file to Record Sequential File...
rem  *
     call SimoNOTE "Identify JobStep Convert Line Sequential to Record Sequential"
     set GETLS080=%DATECARD%
     set PUTRS080=%BaseLib1%\DATA\Asc1\DATECARD.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALAR
     if exist %PUTRS080% call SimoNOTE "Produced DataSet %PUTRS080%"
     if not exist %PUTRS080% set JobStatus=9002
     if not %JobStatus% == 0000 goto :EojNok
rem  * *******************************************************************
rem  * Step   3 of 3  ConvertASCII/TEXT file to Record Sequential File...
rem  *
     call SimoNOTE "Identify JobStep Convert Line Sequential to Record Sequential"
     set GETLS080=%DATECARD%
     set PUTRS080=%BaseLib1%\DATA\Ebc1\DATECARD.DAT
     if exist %PUTRS080% del %PUTRS080%
     run CV80ALER
     if exist %PUTRS080% call SimoNOTE "Produced DataSet %PUTRS080%"
     if not exist %PUTRS080% set JobStatus=9002
     if not %JobStatus% == 0000 goto :EojNok
rem  *
:EojAok
     call SimoNOTE "Finished JobName %JobName%, Job Status is %JobStatus%"
     goto :End
:EojNok
     call SimoNOTE "NOTE ABENDING JobName %JobName%, Job Status is %JobStatus%"
:End
     call SimoNOTE "Conclude SysLog is %SYSLOG%"
     if not "%1" == "nopause" pause

Table of Contents Previous Section Next Section Sample JCL Members

This sample suite of programs has two JCL members. The first JCL member will execute the demonstration program. The second JCL member will create a Date Card file.

Table of Contents Previous Section Next Section Run the Date Validation Job

The following (CBLDATJ1.jcl) is the JCL Member required to run the demonstration program on a Mainframe or a Micro Focus Mainframe-Oriented environment..

//CBLDATJ1 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLDATJ1.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Read a file of Date Cards, edit date, write output.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* The job will read an 80-byte file that contains DATECARD
//* information. The job will also write a file containing the results
//* of the date edit functions..
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//*                     ************
//*                     * CBLDATJ1 *
//*                     ********jcl*
//*                          *
//*                     ************
//*                     * IEFBR14  *
//*                     ********utl*
//*                          *
//*    ************     ************     ************
//*    *  SYSUT1  *-----* CBLDATC1 *-----*  SYSUT2  *
//*    ********dat*     ********cbl*     ********dat*
//*                          *   *
//*                          *   *       ************
//*                          *   *-call--* SIMODATE *
//*                          *           ********cbl*
//*                          *
//*                     ************
//*                     *   EOJ    *
//*                     ************
//*
//* *******************************************************************
//* Step 1 of 2, Delete any previously created file...
//*
//QSAMDELT EXEC PGM=IEFBR14
//DATELIST DD  DSN=SIMOTIME.DATA.DATELIST,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Edit input, create a new output file...
//*
//EXECDAT1 EXEC PGM=CBLDATC1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//SYSUT1   DD  DSN=SIMOTIME.DATA.DATECARD,DISP=SHR
//SYSUT2   DD  DSN=SIMOTIME.DATA.DATELIST,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//SYSOUT   DD  SYSOUT=*
//

Table of Contents Previous Section Next Section Create a Date Card File

The following (CBLDATJ2.jcl) is the JCL Member that may be used to create a date-card file.

//CBLDATJ2 JOB SIMOTIME,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1
//* *******************************************************************
//*       CBLDATJ2.JCL - a JCL Member for Batch Job Processing        *
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   - Create a Sequential Data Set on disk using IEBGENER.
//* Author - SimoTime Technologies
//* Date   - January 24, 1996
//*
//* The first job step (QSAMDELT) will delete any previously created
//* file. The second job step (QCRTDIN1) will create a new file.
//*
//* This set of programs will run on a mainframe under MVS or on a
//* Personal Computer with Windows and Micro Focus Mainframe Express.
//*
//* *******************************************************************
//* Step 1 of 2, Delete any previously created file...
//*
//BLOWAWAY EXEC PGM=IEFBR14
//DATECARD DD  DSN=SIMOTIME.DATA.DATECARD,DISP=(MOD,DELETE,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//*
//* *******************************************************************
//* Step 2 of 2, Create and populate a new QSAM file...
//*
//QCRTDIN1 EXEC PGM=IEBGENER
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  DUMMY
//* :....1....:....2....:....3....:....4....:....5....:....6....:....7.
//SYSUT1   DD  *
DATECARD 19761124
DATECARD 20000401
DATECARD 20001315
DATECARD 2001/01/01
DATECARD 1999-01-32
DATECARD 1999-02/15
DATECARD 1968-07/31
DATECARD 2001/06/31
DATECARD 1998/9/15
DATECARD 2004/10/7
DATECARD 1600/04/01
DATECARD 1700/05/01
DATECARD 3996/05/01
DATECARD 4000/05/01
DATECARD 4004/05/01
DATECARD 3600/05/01
/*
//SYSUT2   DD  DSN=SIMOTIME.DATA.DATECARD,
//             DISP=(NEW,CATLG,DELETE),
//             STORCLAS=MFI,
//             SPACE=(TRK,5),
//             DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PS)
//

Table of Contents Previous Section Next Section The COBOL Programs

This example includes two COBOL programs. The primary program reads a file containing records with a variety of dates in a cccc-mm-dd format. The primary program calls the validation routine to process each date and the edited date information is written to an output file and posted to the SYSOUT device.

Table of Contents Previous Section Next Section The Primary Program

The following (CBLDATC1.cbl) is the source code listing for the demonstration program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    CBLDATC1.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. Once the fee is received by SimoTime   *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies shall not be liable for any direct, indirect,    *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Technologies                                         *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: CBLDATC1.CBL
      * Copy Files:    PASSDATE.CPY
      * Calls to:      SIMODATE
      *****************************************************************
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT SYSUT1-FILE  ASSIGN to       SYSUT1
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is SYSUT1-STATUS.
           SELECT SYSUT2-FILE  ASSIGN to       SYSUT2
                  ORGANIZATION is SEQUENTIAL
                  ACCESS MODE  is SEQUENTIAL
                  FILE STATUS  is SYSUT2-STATUS.
      *
      *****************************************************************
       DATA DIVISION.
       FILE SECTION.
       FD  SYSUT1-FILE
           DATA RECORD    is SYSUT1-RECORD
           .
       01  SYSUT1-RECORD.
           05  SYSUT1-DATA-01.
               10  SYSUT1-KEYWORD  pic X(0008).
               10  SYSUT1-BLANK    pic X.
               10  SYSUT1-INFO     pic X(71).
      *
       FD  SYSUT2-FILE
           DATA RECORD    is SYSUT2-RECORD
           .
       01  SYSUT2-RECORD.
           05  SYSUT2-DATA-01  pic X(00080).
      *
       WORKING-STORAGE SECTION.
       01  SIM-TITLE.
           05  T1 pic X(11) value '* CBLDATC1 '.
           05  T2 pic X(34) value 'Date Processing Examples          '.
           05  T3 pic X(10) value ' v07.01.12'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* CBLDATC1 '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.
      *
       01  SIM-THANKS-01.
           05  C1 pic X(11) value '* CBLDATC1 '.
           05  C2 pic X(32) value 'Thank you for using this program'.
           05  C3 pic X(32) value ' provided from SimoTime Technolo'.
           05  C4 pic X(04) value 'gies'.

       01  SIM-THANKS-02.
           05  C1 pic X(11) value '* CBLDATC1 '.
           05  C2 pic X(32) value 'Please send all inquires or sugg'.
           05  C3 pic X(32) value 'estions to the helpdesk@simotime'.
           05  C4 pic X(04) value '.com'.
      *
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* CBLDATC1 '.
           05  MESSAGE-TEXT.
               10  MESSAGE-TEXT-1  pic X(68)   value SPACES.
               10  MESSAGE-TEXT-2  pic X(188)  value SPACES.
      *
       01  SYSUT1-STATUS.
           05  SYSUT1-STATUS-L     pic X.
           05  SYSUT1-STATUS-R     pic X.
       01  SYSUT1-EOF              pic X       value 'N'.
       01  SYSUT1-OPEN-FLAG        pic X       value 'C'.
      *
       01  SYSUT2-STATUS.
           05  SYSUT2-STATUS-L     pic X.
           05  SYSUT2-STATUS-R     pic X.
       01  SYSUT2-EOF              pic X       value 'N'.
       01  SYSUT2-OPEN-FLAG        pic X       value 'C'.
      *
       01  IO-STATUS.
           05  IO-STAT1            pic X.
           05  IO-STAT2            pic X.
       01  TWO-BYTES.
           05  TWO-BYTES-LEFT      pic X.
           05  TWO-BYTES-RIGHT     pic X.
       01  TWO-BYTES-BINARY        redefines TWO-BYTES pic 9(4) comp.
      *
       01  APPL-RESULT             pic S9(9)   comp.
           88  APPL-AOK            value 0.
           88  APPL-EOF            value 16.
      *
       01  SYSUT1-TOTAL.
           05  filler      pic X(21)   value 'SYSUT1 line count is '.
           05  SYSUT1-LOC  pic 9(7)    value 0.

      *****************************************************************
      * The following copy file of the pass area for calling SIMODATE,
      * the date editing routine.
      *****************************************************************
       COPY PASSDATE.

      *****************************************************************
       PROCEDURE DIVISION.
           perform Z-POST-COPYRIGHT
           perform SYSUT1-OPEN
           perform SYSUT2-OPEN

           perform until SYSUT1-STATUS not = '00'
               perform SYSUT1-READ
               if  SYSUT1-STATUS = '00'
                   add 1 to SYSUT1-LOC
                   perform DATE-FUNCTION-EDIT
                   if  STD-RESPONSE = 0
                       perform DATE-FUNCTION-DISPLAY
                   else
                       move STD-MESSAGE-TEXT to MESSAGE-TEXT
                       perform Z-DISPLAY-CONSOLE-MESSAGE
                       move STD-MESSAGE-TEXT to SYSUT2-DATA-01
                       perform SYSUT2-WRITE
                   end-if
               end-if
           end-perform

           move SYSUT1-TOTAL to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE

           if  APPL-EOF
               move 'is Complete...' to MESSAGE-TEXT
           else
               move 'is ABENDING...' to MESSAGE-TEXT
           end-if
           perform Z-DISPLAY-CONSOLE-MESSAGE

           perform SYSUT2-CLOSE
           perform SYSUT1-CLOSE
           perform Z-THANK-YOU.
           GOBACK.

      *****************************************************************
      * The following routines are in alphabetical sequence..         *
      *****************************************************************

      *****************************************************************
       DATE-FUNCTION-DISPLAY.
           move 'Display the Date Edit Results ' to MESSAGE-TEXT
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Gregorian Date .............. ' to MESSAGE-TEXT
           move STD-GREGORIAN-DATE               to MESSAGE-TEXT(31:10)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Edited Gregorian Date ....... ' to MESSAGE-TEXT
           move STD-DATE-EDITED                  to MESSAGE-TEXT(31:10)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Text for the Date............ ' to MESSAGE-TEXT
           move STD-DATE-VERBAGE                 to MESSAGE-TEXT(31:18)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Julian Date ................. ' to MESSAGE-TEXT
           move STD-JULIAN-DATE                  to MESSAGE-TEXT(31:7)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Days remaining in the year .. ' to MESSAGE-TEXT
           move STD-DAYS-REMAINING               to MESSAGE-TEXT(31:3)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Leap Year Flag (Y or N) ..... ' to MESSAGE-TEXT
           move STD-LEAP-YEAR-YN                 to MESSAGE-TEXT(31:1)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Days in the Month ........... ' to MESSAGE-TEXT
           move STD-MM-DAYS                      to MESSAGE-TEXT(31:2)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           move 'Text for the Month .......... ' to MESSAGE-TEXT
           move STD-MONTH-VERBAGE                to MESSAGE-TEXT(31:10)
           move MESSAGE-TEXT                     to SYSUT2-DATA-01
           perform Z-DISPLAY-CONSOLE-MESSAGE
           perform SYSUT2-WRITE

           exit.

      *****************************************************************
       DATE-FUNCTION-EDIT.
           move all '*' to MESSAGE-TEXT-1
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move all '*' to SYSUT2-DATA-01
           perform SYSUT2-WRITE

           move SYSUT1-DATA-01 to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           move SYSUT1-DATA-01 to SYSUT2-DATA-01
           perform SYSUT2-WRITE

           move SPACES to STD-GREGORIAN-4-EDIT
           move 'EDITDATE'           to STD-REQUEST
           move '-'                  to STD-DATE-EDIT-BYTE
           move SYSUT1-INFO          to STD-GREGORIAN-4-EDIT
           call 'SIMODATE' using STD-SIMODATE

           exit.

      *****************************************************************
      * I/O ROUTINES FOR SYSUT1...                                    *
      *****************************************************************
       SYSUT1-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SYSUT1-FILE
           if  SYSUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SYSUT1-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SYSUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SYSUT1-READ.
           read SYSUT1-FILE
           if  SYSUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SYSUT1-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if
           if  APPL-AOK
               CONTINUE
           else
               if  APPL-EOF
                   move 'Y' to SYSUT1-EOF
               else
                   move 'SYSUT1-Failure-GET...' to MESSAGE-TEXT
                   perform Z-DISPLAY-CONSOLE-MESSAGE
                   move SYSUT1-STATUS to IO-STATUS
                   perform Z-DISPLAY-IO-STATUS
                   perform Z-ABEND-PROGRAM
               end-if
           end-if
           exit.
      *---------------------------------------------------------------*
       SYSUT1-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open input SYSUT1-FILE
           if  SYSUT1-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SYSUT1-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SYSUT1-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SYSUT1-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * I/O ROUTINES FOR SYSUT2...                                    *
      *****************************************************************
       SYSUT2-WRITE.
           if  SYSUT2-OPEN-FLAG = 'C'
               perform SYSUT2-OPEN
           end-if
           write SYSUT2-RECORD
           if  SYSUT2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
           else
               if  SYSUT2-STATUS = '10'
                   add 16 to ZERO giving APPL-RESULT
               else
                   add 12 to ZERO giving APPL-RESULT
               end-if
           end-if.
           if  APPL-AOK
               CONTINUE
           else
               move 'SYSUT2-Failure-WRITE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SYSUT2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SYSUT2-OPEN.
           add 8 to ZERO giving APPL-RESULT.
           open output SYSUT2-FILE
           if  SYSUT2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'O' to SYSUT2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SYSUT2-Failure-OPEN...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SYSUT2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.
      *---------------------------------------------------------------*
       SYSUT2-CLOSE.
           add 8 to ZERO giving APPL-RESULT.
           close SYSUT2-FILE
           if  SYSUT2-STATUS = '00'
               subtract APPL-RESULT from APPL-RESULT
               move 'C' to SYSUT2-OPEN-FLAG
           else
               add 12 to ZERO giving APPL-RESULT
           end-if
           if  APPL-AOK
               CONTINUE
           else
               move 'SYSUT2-Failure-CLOSE...' to MESSAGE-TEXT
               perform Z-DISPLAY-CONSOLE-MESSAGE
               move SYSUT2-STATUS to IO-STATUS
               perform Z-DISPLAY-IO-STATUS
               perform Z-ABEND-PROGRAM
           end-if
           exit.

      *****************************************************************
      * The following Z-Routines perform administrative tasks         *
      * for this program.                                             *
      *****************************************************************

      *****************************************************************
      * ABEND the program, post a message to the console and issue    *
      * a STOP RUN.                                                   *
      *****************************************************************
       Z-ABEND-PROGRAM.
           if  MESSAGE-TEXT not = SPACES
               perform Z-DISPLAY-CONSOLE-MESSAGE
           end-if
           move 'PROGRAM-IS-ABENDING...'  to MESSAGE-TEXT
           perform Z-DISPLAY-CONSOLE-MESSAGE
           add 12 to ZERO giving RETURN-CODE
           STOP RUN.
      *    exit.

      *****************************************************************
      * Display CONSOLE messages...                                   *
      *****************************************************************
       Z-DISPLAY-CONSOLE-MESSAGE.
           if MESSAGE-TEXT-2 = SPACES
               display MESSAGE-BUFFER(1:79)
           else
               display MESSAGE-BUFFER
           end-if
           move all SPACES to MESSAGE-TEXT
           exit.

      *****************************************************************
      * Display the file status bytes. This routine will display as   *
      * two digits if the full two byte file status is numeric. If    *
      * second byte is non-numeric then it will be treated as a       *
      * binary number.                                                *
      *****************************************************************
       Z-DISPLAY-IO-STATUS.
           if  IO-STATUS not NUMERIC
           or  IO-STAT1    = '9'
               subtract TWO-BYTES-BINARY from TWO-BYTES-BINARY
               move IO-STAT2 to TWO-BYTES-RIGHT
               display '* CBLDATC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY upon console
               display '* CBLDATC1 File-Status-' IO-STAT1 '/'
                       TWO-BYTES-BINARY
           else
               display '* CBLDATC1 File-Status-' IO-STATUS upon console
               display '* CBLDATC1 File-Status-' IO-STATUS
           end-if
           exit.

      *****************************************************************
       Z-POST-COPYRIGHT.
           display SIM-TITLE
           display SIM-COPYRIGHT
           exit.

      *****************************************************************
       Z-THANK-YOU.
           display SIM-THANKS-01
           display SIM-THANKS-02
           exit.

      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section The Date Validation Routine

The following (SIMODATE.cbl) is the source code listing for the date validation, formatting and conversion routine.

       IDENTIFICATION DIVISION.
       PROGRAM-ID.    SIMODATE.
       AUTHOR.        SIMOTIME TECHNOLOGIES.
      *****************************************************************
      * Copyright (C) 1987-2019 SimoTime Technologies.                *
      *                                                               *
      * All rights reserved.  Unpublished, all rights reserved under  *
      * copyright law and international treaty.  Use of a copyright   *
      * notice is precautionary only and does not imply publication   *
      * or disclosure.                                                *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any non-commercial purpose and without fee is hereby      *
      * granted, provided the SimoTime copyright notice appear on all *
      * copies of the software. The SimoTime name or Logo may not be  *
      * used in any advertising or publicity pertaining to the use    *
      * of the software without the written permission of SimoTime    *
      * Technologies.                                                 *
      *                                                               *
      * Permission to use, copy, modify and distribute this software  *
      * for any commercial purpose requires a fee to be paid to       *
      * SimoTime Technologies. Once the fee is received by SimoTime   *
      * the latest version of the software will be delivered and a    *
      * license will be granted for use within an enterprise,         *
      * provided the SimoTime copyright notice appear on all copies   *
      * of the software. The SimoTime name or Logo may not be used    *
      * in any advertising or publicity pertaining to the use of the  *
      * software without the written permission of SimoTime           *
      * Technologies.                                                 *
      *                                                               *
      * SimoTime Technologies makes no warranty or representations    *
      * about the suitability of the software for any purpose. It is  *
      * provided "AS IS" without any expressed or implied warranty,   *
      * including the implied warranties of merchantability, fitness  *
      * for a particular purpose and non-infringement. SimoTime       *
      * Technologies shall not be liable for any direct, indirect,    *
      * special or consequential damages resulting from the loss of   *
      * use, data or projects, whether in an action of contract or    *
      * tort, arising out of or in connection with the use or         *
      * performance of this software                                  *
      *                                                               *
      * SimoTime Technologies                                         *
      * 15 Carnoustie Drive                                           *
      * Novato, CA 94949-5849                                         *
      * 415.883.6565                                                  *
      *                                                               *
      * RESTRICTED RIGHTS LEGEND                                      *
      * Use, duplication, or disclosure by the Government is subject  *
      * to restrictions as set forth in subparagraph (c)(1)(ii) of    *
      * the Rights in Technical Data and Computer Software clause at  *
      * DFARS 52.227-7013 or subparagraphs (c)(1) and (2) of          *
      * Commercial  Computer Software - Restricted Rights  at 48      *
      * CFR 52.227-19, as applicable.  Contact SimoTime Technologies, *
      * 15 Carnoustie Drive, Novato, CA 94949-5849.                   *
      *                                                               *
      *****************************************************************
      *      This program is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *                                                               *
      *****************************************************************
      *
      *****************************************************************
      * Source Member: SIMODATE.CBL
      * Copy Files:    PASSDATE.CPY
      *****************************************************************
      *
      * SIMODATE - edits and formats a gregorian date ccyymmdd. It also
      * provides additional information such as:
      *
      * 1. Identify leap year
      * 2. Provide a Julian Date
      * 3. Provide a text date - for example, January 1, 2001
      * 4. Provide days-in-month
      * and more...
      *
      * CALLING PROTOCOL
      * ----------------
      *    call 'SIMODATE' using STD-SIMODATE
      *
      *    01  STD-SIMODATE.
      *        05  STD-REQUEST             pic X(8).
      *        05  STD-RESPONSE            pic 9(4).
      *        05  STD-MESSAGE-TEXT        pic X(68).
      *        05  STD-GREGORIAN-4-EDIT    pic X(10).
      *        05  STD-EDITED-INFO.
      *            10  STD-DEBUG-INFO      pic X(8).
      *            10  STD-LEAP-YEAR-YN    pic X.
      *            10  STD-MONTH-VERBAGE   pic X(10).
      *            10  STD-MM-DAYS         pic 99.
      *            10  STD-GREGORIAN-DATE  pic 9(8).
      *            10  STD-JULIAN-DATE     pic 9(7).
      *            10  STD-JULIAN-VALUE    redefines STD-JULIAN-DATE.
      *                15  STD-JULIAN-CCYY pic 9(4).
      *                15  STD-JULIAN-DAY  pic 9(3).
      *            10  STD-DAYS-REMAINING  pic 9(3).
      *            10  STD-DATE-VERBAGE    pic X(18).
      *            10  STD-DATE-EDIT-BYTE  pic X.
      *            10  STD-DATE-EDITED     pic X(10).
      *
      *****************************************************************
      *
      * MAINTENANCE
      * -----------
      * 1997/02/27 Simmons, Created program.
      * 2004/01/26 Simmons, Mike added the check for 4000th year
      *                     increments are not leap years.
      *
      *****************************************************************
      *
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      *
      *****************************************************************
      *    Data-structure for Title and Copyright...
      *****************************************************************
       01  SIM-TITLE.
           05  T1 pic X(11) value '* SIMODATE '.
           05  T2 pic X(34) value 'Process a Date Request            '.
           05  T3 pic X(10) value ' v13.06.19'.
           05  T4 pic X(24) value ' http://www.simotime.com'.
       01  SIM-COPYRIGHT.
           05  C1 pic X(11) value '* SIMODATE '.
           05  C2 pic X(20) value 'Copyright 1987-2019 '.
           05  C3 pic X(28) value '   SimoTime Technologies    '.
           05  C4 pic X(20) value ' All Rights Reserved'.

      *****************************************************************
       01  FIRST-TIME              pic X       value 'Y'.

       01  IX-1                    pic 999     value 0.
       01  IX-2                    pic 999     value 0.
       01  WORK-N-7                pic 9(7)    value 0.

       01  DATE-WORK-ALPHA.
           05  DATE-WORK-A-CCYY    pic X(4)    value SPACES.
           05  DATE-WORK-A-MM      pic X(2)    value SPACES.
           05  DATE-WORK-A-DD      pic X(2)    value SPACES.

       01  DATE-WORK-NUMERIC.
           05  DATE-WORK-N-CCYY    pic 9(4)    value 0.
           05  DATE-WORK-N-MM      pic 9(2)    value 0.
           05  DATE-WORK-N-DD      pic 9(2)    value 0.

       01  MONTH-TABLE-DATA.
           05  filler              pic X(10)   value 'January   '.
           05  filler              pic X(10)   value 'February  '.
           05  filler              pic X(10)   value 'March     '.
           05  filler              pic X(10)   value 'April     '.
           05  filler              pic X(10)   value 'May       '.
           05  filler              pic X(10)   value 'June      '.
           05  filler              pic X(10)   value 'July      '.
           05  filler              pic X(10)   value 'August    '.
           05  filler              pic X(10)   value 'September '.
           05  filler              pic X(10)   value 'October   '.
           05  filler              pic X(10)   value 'November  '.
           05  filler              pic X(10)   value 'December  '.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 28.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 30.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 30.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 30.
           05  filler              pic 99      value 31.
           05  filler              pic 99      value 30.
           05  filler              pic 99      value 31.
       01  MONTH-TABLE             redefines MONTH-TABLE-DATA.
           05  MONTH-VERBAGE       pic X(10)   occurs 12 times.
           05  MONTH-COUNT-OF-DAYS pic 99      occurs 12 times.

       01  JULIAN-DATE.
           05  JULIAN-CCYY         pic 9(4)    value 0.
           05  JULIAN-DDD          pic 9(3)    value 0.

       01  DATE-VERBAGE            pic X(18)   value SPACES.

       01  DAY-OF-WEEK-DATA.
           05  filler              pic X(10)   value 'Sunday    '.
           05  filler              pic X(10)   value 'Monday    '.
           05  filler              pic X(10)   value 'Tuesday   '.
           05  filler              pic X(10)   value 'Wednesday '.
           05  filler              pic X(10)   value 'Thursday  '.
           05  filler              pic X(10)   value 'Friday    '.
           05  filler              pic X(10)   value 'Saturday  '.
       01  DOW-TABLE               redefines DAY-OF-WEEK-DATA.
           05  DOW-VERBAGE         pic X(10)   occurs 7 times.
       01  DOW-IDX                 pic 9       value 0.

      *****************************************************************
       01  MESSAGE-BUFFER.
           05  MESSAGE-HEADER      pic X(11)   value '* SIMODATE '.
           05  MESSAGE-TEXT        pic X(68).

       01  DIFF-OF-YEARS           pic 9(4)    value 0.
       01  DIFF-OF-DAYS            pic 9(7)    value 0.
       01  DIFF-OF-WEEKS           pic 9(7)    value 0.
       01  MULTIPLE-YEARS          pic 9(7)    value 0.
       01  NUMBER-OF-LEAP-YEARS    pic 9(7)    value 0.
       01  HOLD-REMAINDER-1        pic 9(7)    value 0.
       01  HOLD-REMAINDER-2        pic 9(7)    value 0.
       01  REGISTER-7-0            pic 9(7)    value 0.

       COPY PASSDIFF.

      *****************************************************************
       LINKAGE SECTION.
       COPY PASSDATE.

      *****************************************************************
      * Mainline processing routine...
      *****************************************************************
       PROCEDURE DIVISION using STD-SIMODATE.

           add 20 to ZERO giving STD-RESPONSE
           move SPACES to STD-MESSAGE-TEXT

           if  FIRST-TIME not = 'N'
               if  STD-DEBUG-INFO = 'DEBUG   '
               or  STD-DEBUG-INFO = 'TRACE   '
                   perform Z-POST-COPYRIGHT
               end-if
               move 'N' to FIRST-TIME
           end-if

           evaluate STD-REQUEST
               when 'EDITDATE' perform EDIT-DATE-FUNCTION
               when 'EDITGDAT' perform ACTION-GDAT-REQUEST
               when OTHER      add 16 to ZERO giving RETURN-CODE
                               move '0016' to STD-RESPONSE
           end-evaluate

           if  STD-RESPONSE = 20
           and STD-MESSAGE-TEXT = SPACES
               subtract STD-RESPONSE from STD-RESPONSE
           end-if

           GOBACK.

      *****************************************************************
      *    This routine will accept dates in the following formats
      *     ccyymmdd
      *      ccyy/mm/dd
      *      ccyy-mm-dd
      *      ccyy.mm.dd
      *****************************************************************
       ACTION-GDAT-REQUEST.
           move SPACES to DATE-WORK-ALPHA
           add 1 to ZERO giving IX-2
           move STD-GREGORIAN-4-EDIT to DATE-WORK-A-CCYY
           if  DATE-WORK-A-CCYY not NUMERIC
               move 'NOK for Date Value, CCYY not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           else
               add 4 to IX-2
           end-if
      *    --------------------------------------------------------
      *    Possible non-numeric separator between CCYY and MM
           if  STD-GREGORIAN-4-EDIT(IX-2:1) not NUMERIC
               add 1 to IX-2
           end-if
           move STD-GREGORIAN-4-EDIT(IX-2:2) to DATE-WORK-A-MM
           if  DATE-WORK-A-MM not NUMERIC
               move DATE-WORK-A-MM(1:1) to DATE-WORK-A-MM(2:1)
               move ZERO                to DATE-WORK-A-MM(1:1)
               add 1 to IX-2
           else
               add 2 to IX-2
           end-if
      *    --------------------------------------------------------
      *    Possible non-numeric separator between MM and DD
           if  STD-GREGORIAN-4-EDIT(IX-2:1) not NUMERIC
               add 1 to IX-2
           end-if
           move STD-GREGORIAN-4-EDIT(IX-2:2) to DATE-WORK-A-DD
           if  DATE-WORK-A-DD not NUMERIC
               move DATE-WORK-A-DD(1:1) to DATE-WORK-A-DD(2:1)
               move ZERO                to DATE-WORK-A-DD(1:1)
           end-if
           if  DATE-WORK-A-MM not NUMERIC
               move 'NOK for Date Value, MM not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           if  DATE-WORK-A-DD not NUMERIC
               move 'NOK for Date Value, DD not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           move 'WIP for Date Function...' to MESSAGE-TEXT
           perform Z-POST-CONDITIONAL-TRACE
           move DATE-WORK-ALPHA to DATE-WORK-NUMERIC
           perform FUNCTION-LEAP-YEAR.

           perform FUNCTION-FOR-MONTH
           perform FUNCTION-FOR-DAY
           perform FUNCTION-CREATE-TXT-DATE
           perform FUNCTION-CREATE-NBR-DATE
           perform FUNCTION-CONVERT-GDATE-2-JDATE
           perform FUNCTION-CALCULATE-DAYS-LEFT

           perform FUNCTION-DAY-OF-WEEK

      *    ------------------------------------------------------------
      *    Determine AOK for Date Message...
           move 'AOK for Date Function...' to MESSAGE-TEXT
           perform Z-POST-CONDITIONAL-TRACE

           exit.

      *****************************************************************
      *>   This routine will accept dates in the following formats
      *>     ccyymmdd
      *>     ccyy/mm/dd
      *>     ccyy-mm-dd
      *>     ccyy.mm.dd
      *****************************************************************
       EDIT-DATE-FUNCTION.
           move SPACES to DATE-WORK-ALPHA
           add 1 to ZERO giving IX-2
           move STD-GREGORIAN-4-EDIT to DATE-WORK-A-CCYY
           if  DATE-WORK-A-CCYY not NUMERIC
               move 'NOK for Date Value, CCYY not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           else
               add 4 to IX-2
           end-if
      *>   --------------------------------------------------------
      *>   Possible non-numeric separator between CCYY and MM
           if  STD-GREGORIAN-4-EDIT(IX-2:1) not NUMERIC
               add 1 to IX-2
           end-if
           move STD-GREGORIAN-4-EDIT(IX-2:2) to DATE-WORK-A-MM
           if  DATE-WORK-A-MM not NUMERIC
               move DATE-WORK-A-MM(1:1) to DATE-WORK-A-MM(2:1)
               move ZERO                to DATE-WORK-A-MM(1:1)
               add 1 to IX-2
           else
               add 2 to IX-2
           end-if
      *>   --------------------------------------------------------
      *>   Possible non-numeric separator between MM and DD
           if  STD-GREGORIAN-4-EDIT(IX-2:1) not NUMERIC
               add 1 to IX-2
           end-if
           move STD-GREGORIAN-4-EDIT(IX-2:2) to DATE-WORK-A-DD
           if  DATE-WORK-A-DD not NUMERIC
               move DATE-WORK-A-DD(1:1) to DATE-WORK-A-DD(2:1)
               move ZERO                to DATE-WORK-A-DD(1:1)
           end-if
           if  DATE-WORK-A-MM not NUMERIC
               move 'NOK for Date Value, MM not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           if  DATE-WORK-A-DD not NUMERIC
               move 'NOK for Date Value, DD not numeric value...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           move 'WIP for Date Function...' to MESSAGE-TEXT
           perform Z-POST-CONDITIONAL-TRACE
           move DATE-WORK-ALPHA to DATE-WORK-NUMERIC
      *   ------------------------------------------------------------
      *   Determine if a leap year, it is not true that every fourth
      *   year is a leap year.
      *
      *   if CCYY is divisible by 4 it is a  leap year
      *      except
      *      if divisible by 100 then it is not a leap year
      *         except
      *         if divisible by 400 then it is a leap year
      *            except
      *            if divisible by 4000 then it is not a leap year.
      *
      *    1600,2000, etc... are leap years
      *    1700,1800,1900 are not leap years
      *    4000,8000,etc... are not leap years
      *
      *    In other words the 100th year increments are not leap
      *    years with the exception that every 400th year increment
      *    is a leap year except every 4000th year is not a leap year.
      *
           move 'N' to STD-LEAP-YEAR-YN
           add 28 to ZERO giving MONTH-COUNT-OF-DAYS(2)
           move 'WIP for Date, not a Leap Year...' to MESSAGE-TEXT
           divide DATE-WORK-N-CCYY by 4 giving WORK-N-7
           multiply 4 by WORK-N-7
           if  WORK-N-7 = DATE-WORK-N-CCYY
               divide DATE-WORK-N-CCYY by 100 giving WORK-N-7
               multiply 100 by WORK-N-7
               if  WORK-N-7  = DATE-WORK-N-CCYY
                   divide DATE-WORK-N-CCYY by 400 giving WORK-N-7
                   multiply 400 by WORK-N-7
                   if  WORK-N-7 = DATE-WORK-N-CCYY
                       divide DATE-WORK-N-CCYY by 4000 giving WORK-N-7
                       multiply 4000 by WORK-N-7
                       if  WORK-N-7 not = DATE-WORK-N-CCYY
                           move 'Y' to STD-LEAP-YEAR-YN
                       end-if
                   end-if
               else
                   move 'Y' to STD-LEAP-YEAR-YN
               end-if
               if  STD-LEAP-YEAR-YN = 'Y'
                   move 'Y' to STD-LEAP-YEAR-YN
                   add 29 to ZERO giving MONTH-COUNT-OF-DAYS(2)
                   move 'WIP for Date, it is a Leap Year...'
                     to MESSAGE-TEXT
               end-if
           end-if
           perform Z-POST-CONDITIONAL-TRACE
      *>   ------------------------------------------------------------
      *>   Test for a valid month...
           if  DATE-WORK-N-MM > 0
           and DATE-WORK-N-MM < 13
               move 'WIP for Date, month is ?????????' to MESSAGE-TEXT
               move MONTH-VERBAGE(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(24:10)
               perform Z-POST-CONDITIONAL-TRACE
               move MONTH-VERBAGE(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(24:10)
               move MONTH-VERBAGE(DATE-WORK-N-MM) to STD-MONTH-VERBAGE
           else
               move 'NOK for Date Value, MM not 1 through 12...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND

           end-if
      *>   ------------------------------------------------------------
      *>   Test for a valid day...
           if  DATE-WORK-N-DD > 0
           and DATE-WORK-N-DD < MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM) + 1
               move 'WIP for Date, month has ?? days' to MESSAGE-TEXT
               move MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(25:2)
               perform Z-POST-CONDITIONAL-TRACE
           else
               move 'NOK for Day Value, DD not within month range...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           move MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM)
             to STD-MM-DAYS

      *>   ------------------------------------------------------------
      *>   Create text version of the date. This is a sixteen character
      *>   field (DATE-VERBAGE) that is left-justified in the following
      *>   format...      month dd, ccyy
           move 'WIP for Date, ' to MESSAGE-TEXT
           move MONTH-VERBAGE(DATE-WORK-N-MM) to DATE-VERBAGE
           subtract IX-2 from IX-2
           inspect DATE-VERBAGE tallying IX-2
                   for CHARACTERS before SPACE
           add 2 to IX-2
           if  DATE-WORK-A-DD(1:1) = '0'
               move DATE-WORK-A-DD(2:1) to DATE-VERBAGE(IX-2:1)
               add 1 to IX-2
           else
               move DATE-WORK-A-DD to DATE-VERBAGE(IX-2:2)
               add 2 to IX-2
           end-if
           move ', ' to DATE-VERBAGE(IX-2:2)
           add 2 to IX-2
           move DATE-WORK-N-CCYY to DATE-VERBAGE(IX-2:4)

           move DATE-VERBAGE to MESSAGE-TEXT(15:18)
           perform Z-POST-CONDITIONAL-TRACE

           move DATE-VERBAGE to STD-DATE-VERBAGE

      *>   ------------------------------------------------------------
      *>   Create numeric date for display or print...
           move DATE-WORK-A-CCYY   to STD-DATE-EDITED
           move STD-DATE-EDIT-BYTE to STD-DATE-EDITED(5:1)
           move DATE-WORK-A-MM     to STD-DATE-EDITED(6:2)
           move STD-DATE-EDIT-BYTE to STD-DATE-EDITED(8:1)
           move DATE-WORK-A-DD     to STD-DATE-EDITED(9:2)
           move DATE-WORK-NUMERIC  to STD-GREGORIAN-DATE

      *>   ------------------------------------------------------------
      *>   Determine Julian Date...
           move 'WIP for Date, Julian is CCYYDDD' to MESSAGE-TEXT
           move DATE-WORK-N-CCYY to JULIAN-CCYY
           add DATE-WORK-N-DD to ZERO giving JULIAN-DDD
           add 1 to ZERO giving IX-2
           perform until IX-2 = DATE-WORK-N-MM
                      or IX-2 > 12
               add MONTH-COUNT-OF-DAYS(IX-2) to JULIAN-DDD
               add 1 to IX-2
           end-perform
           move JULIAN-DATE to MESSAGE-TEXT(25:7)
           perform Z-POST-CONDITIONAL-TRACE
           move JULIAN-DATE to STD-JULIAN-DATE

      *>   ------------------------------------------------------------
      *>   Calculate remaining days in the year...
           if  STD-LEAP-YEAR-YN = 'Y'
               subtract STD-JULIAN-DAY from 366
                 giving STD-DAYS-REMAINING
           else
               subtract STD-JULIAN-DAY from 365
                 giving STD-DAYS-REMAINING
           end-if

      *>   ------------------------------------------------------------
      *>   Determine AOK for Date Message...
           move 'AOK for Date Function...' to MESSAGE-TEXT
           perform Z-POST-CONDITIONAL-TRACE
           exit.

      *****************************************************************
       FUNCTION-CREATE-TXT-DATE.
      *    ------------------------------------------------------------
      *    Create text version of the date. This is a sixteen character
      *    field (DATE-VERBAGE) that is left-justified in the following
      *    format...      month dd, ccyy
           move 'WIP for Date, ' to MESSAGE-TEXT
           move MONTH-VERBAGE(DATE-WORK-N-MM) to DATE-VERBAGE
           subtract IX-2 from IX-2
           inspect DATE-VERBAGE tallying IX-2
                   for CHARACTERS before SPACE
           add 2 to IX-2
           if  DATE-WORK-A-DD(1:1) = '0'
               move DATE-WORK-A-DD(2:1) to DATE-VERBAGE(IX-2:1)
               add 1 to IX-2
           else
               move DATE-WORK-A-DD to DATE-VERBAGE(IX-2:2)
               add 2 to IX-2
           end-if
           move ', ' to DATE-VERBAGE(IX-2:2)
           add 2 to IX-2
           move DATE-WORK-N-CCYY to DATE-VERBAGE(IX-2:4)

           move DATE-VERBAGE to MESSAGE-TEXT(15:18)
           perform Z-POST-CONDITIONAL-TRACE

           move DATE-VERBAGE to STD-DATE-VERBAGE
           exit.

      *****************************************************************
       FUNCTION-DAY-OF-WEEK.
      *    Determine the Day of a week as a number and text.
      *   ----------------------------------------------------------- *
           move ZERO to STD-DAY-OF-WEEK-NBR
           move 'Unknown   ' to STD-DAY-OF-WEEK-TXT
           add 1600001 to ZERO giving DDF-JULIAN-DATE-1
           move STD-JULIAN-DATE to DDF-JULIAN-DATE-2
           perform FUNCTION-DATE-DIFFERENCE
           divide DDF-DIFFERENCE-IN-DAYS by 7
           giving DIFF-OF-WEEKS remainder DOW-IDX
           evaluate DOW-IDX
             when 0     add 6 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 1     add 7 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 2     add 1 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 3     add 2 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 4     add 3 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 5     add 4 to ZERO giving STD-DAY-OF-WEEK-NBR
             when 6     add 5 to ZERO giving STD-DAY-OF-WEEK-NBR
           end-evaluate
           if  STD-DAY-OF-WEEK-NBR > 0
           and STD-DAY-OF-WEEK-NBR < 8
               move DOW-VERBAGE(STD-DAY-OF-WEEK-NBR)
                 to STD-DAY-OF-WEEK-TXT
           else
               move ZERO to STD-DAY-OF-WEEK-NBR
               move 'Unknown   ' to STD-DAY-OF-WEEK-TXT
           end-if
           exit.

      *****************************************************************
       FUNCTION-LEAP-YEAR.
      *   ----------------------------------------------------------- *
      *   Determine if a leap year, it is not true that every fourth
      *   year is a leap year.
      *
      *   if CCYY is divisible by 4 it is a  leap year
      *      except
      *      if divisible by 100 then it is not a leap year
      *         except
      *         if divisible by 400 then it is a leap year
      *            except
      *            if divisible by 4000 then it is not a leap year.
      *
      *    1600,2000, etc... are leap years
      *    1700,1800,1900 are not leap years
      *    4000,8000,etc... are not leap years
      *
      *    In other words the 100th year increments are not leap
      *    years with the exception that every 400th year increment
      *    is a leap year except every 4000th year is not a leap year.
      *
           move 'N' to STD-LEAP-YEAR-YN
           add 28 to ZERO giving MONTH-COUNT-OF-DAYS(2)
           move 'WIP for Date, not a Leap Year...' to MESSAGE-TEXT
           divide DATE-WORK-N-CCYY by 4 giving WORK-N-7
           multiply 4 by WORK-N-7
           if  WORK-N-7 = DATE-WORK-N-CCYY
               divide DATE-WORK-N-CCYY by 100 giving WORK-N-7
               multiply 100 by WORK-N-7
               if  WORK-N-7  = DATE-WORK-N-CCYY
                   divide DATE-WORK-N-CCYY by 400 giving WORK-N-7
                   multiply 400 by WORK-N-7
                   if  WORK-N-7 = DATE-WORK-N-CCYY
                       divide DATE-WORK-N-CCYY by 4000 giving WORK-N-7
                       multiply 4000 by WORK-N-7
                       if  WORK-N-7 not = DATE-WORK-N-CCYY
                           move 'Y' to STD-LEAP-YEAR-YN
                       end-if
                   end-if
               else
                   move 'Y' to STD-LEAP-YEAR-YN
               end-if
               if  STD-LEAP-YEAR-YN = 'Y'
                   move 'Y' to STD-LEAP-YEAR-YN
                   add 29 to ZERO giving MONTH-COUNT-OF-DAYS(2)
                   move 'WIP for Date, it is a Leap Year...'
                     to MESSAGE-TEXT
               end-if
           end-if
           perform Z-POST-CONDITIONAL-TRACE

           exit.

      *****************************************************************
       FUNCTION-FOR-MONTH.
      *    ------------------------------------------------------------
      *    Test for a valid month...
           if  DATE-WORK-N-MM > 0
           and DATE-WORK-N-MM < 13
               move 'WIP for Date, month is ?????????' to MESSAGE-TEXT
               move MONTH-VERBAGE(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(24:10)
               perform Z-POST-CONDITIONAL-TRACE
               move MONTH-VERBAGE(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(24:10)
               move MONTH-VERBAGE(DATE-WORK-N-MM) to STD-MONTH-VERBAGE
           else
               move 'NOK for Date Value, MM not 1 through 12...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND

           end-if
           exit.

      *****************************************************************
       FUNCTION-FOR-DAY.
      *    ------------------------------------------------------------
      *    Test for a valid day...
           if  DATE-WORK-N-DD > 0
           and DATE-WORK-N-DD < MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM) + 1
               move 'WIP for Date, month has ?? days' to MESSAGE-TEXT
               move MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM)
                 to MESSAGE-TEXT(25:2)
               perform Z-POST-CONDITIONAL-TRACE
           else
               move 'NOK for Day Value, DD not within month range...'
                 to MESSAGE-TEXT
               perform Z-POST-ABEND
           end-if
           move MONTH-COUNT-OF-DAYS(DATE-WORK-N-MM)
             to STD-MM-DAYS
           exit.

      *****************************************************************
       FUNCTION-CREATE-NBR-DATE.
      *    ------------------------------------------------------------
      *    Create numeric date for display or print...
           move DATE-WORK-A-CCYY   to STD-DATE-EDITED
           move STD-DATE-EDIT-BYTE to STD-DATE-EDITED(5:1)
           move DATE-WORK-A-MM     to STD-DATE-EDITED(6:2)
           move STD-DATE-EDIT-BYTE to STD-DATE-EDITED(8:1)
           move DATE-WORK-A-DD     to STD-DATE-EDITED(9:2)
           move DATE-WORK-NUMERIC  to STD-GREGORIAN-DATE
           exit.

      *****************************************************************
       FUNCTION-CONVERT-GDATE-2-JDATE.
      *    ------------------------------------------------------------
      *    Determine Julian Date...
           move 'WIP for Date, Julian is CCYYDDD' to MESSAGE-TEXT
           move DATE-WORK-N-CCYY to JULIAN-CCYY
           add DATE-WORK-N-DD to ZERO giving JULIAN-DDD
           add 1 to ZERO giving IX-2
           perform until IX-2 = DATE-WORK-N-MM
                      or IX-2 > 12
               add MONTH-COUNT-OF-DAYS(IX-2) to JULIAN-DDD
               add 1 to IX-2
           end-perform
           move JULIAN-DATE to MESSAGE-TEXT(25:7)
           perform Z-POST-CONDITIONAL-TRACE
           move JULIAN-DATE to STD-JULIAN-DATE
           exit.

      *****************************************************************
       FUNCTION-CALCULATE-DAYS-LEFT.
      *    ------------------------------------------------------------
      *    Calculate remaining days in the year...
           if  STD-LEAP-YEAR-YN = 'Y'
               subtract STD-JULIAN-DAY from 366
                 giving STD-DAYS-REMAINING
           else
               subtract STD-JULIAN-DAY from 365
                 giving STD-DAYS-REMAINING
           end-if
           exit.



      *****************************************************************
       FUNCTION-DATE-DIFFERENCE.
      *    Calculate difference of years...
           subtract DDF-JULIAN-CCYY-1 from DDF-JULIAN-CCYY-2
             giving DIFF-OF-YEARS
      *    Calculate difference of days...
           subtract DIFF-OF-DAYS from DIFF-OF-DAYS
           if  DIFF-OF-YEARS = 0
               subtract DDF-JULIAN-DAY-1 from DDF-JULIAN-DAY-2
                 giving DIFF-OF-DAYS
           else
               add DDF-DAYS-REMAINING-1 to DIFF-OF-DAYS
               add DDF-JULIAN-DAY-2     to DIFF-OF-DAYS
           end-if
      *    Calculate for multiple years ignoring leap years
           if  DIFF-OF-YEARS > 1
               subtract 1 from DIFF-OF-YEARS giving MULTIPLE-YEARS
               multiply 365 by MULTIPLE-YEARS giving REGISTER-7-0
               add REGISTER-7-0 to DIFF-OF-DAYS
           end-if
      *    Adjust difference of days for leap-year cycle...
           if  DIFF-OF-YEARS > 1
               perform FUNCTION-DATE-DIFF-LEAP
               add NUMBER-OF-LEAP-YEARS to DIFF-OF-DAYS
           end-if
           add DIFF-OF-DAYS to ZERO giving DDF-DIFFERENCE-IN-DAYS
           exit.

      *****************************************************************
       FUNCTION-DATE-DIFF-LEAP.
      *    Calculate years to next leap year...
           divide DDF-JULIAN-CCYY-1 by 4 giving MULTIPLE-YEARS
                  remainder HOLD-REMAINDER-1
      *    Calculate number of years between primary and secondary...
           subtract 1 from DIFF-OF-YEARS giving MULTIPLE-YEARS
           add HOLD-REMAINDER-1 to MULTIPLE-YEARS
           divide MULTIPLE-YEARS by 4 giving NUMBER-OF-LEAP-YEARS
      *    Adjust difference of days for 400-year leap-year cycle...
           perform FUNCTION-DATE-DIFF-LEAP-400
           exit.

      *****************************************************************
       FUNCTION-DATE-DIFF-LEAP-400.
      *    Calculate years to next leap year 400 exception...
           divide DDF-JULIAN-CCYY-1 by 400 giving MULTIPLE-YEARS
                  remainder HOLD-REMAINDER-2
      *    Calculate number of years between primary and secondary...
           subtract 1 from DIFF-OF-YEARS giving MULTIPLE-YEARS
           add HOLD-REMAINDER-2 to MULTIPLE-YEARS
           divide MULTIPLE-YEARS by 400 giving REGISTER-7-0
           subtract REGISTER-7-0 from NUMBER-OF-LEAP-YEARS
      *    Adjust difference of days for 4-year leap-year cycle...
           exit.




      *****************************************************************
      *    Display Copyright or Program Message...
      *    ------------------------------------------------------------
       Z-POST-ABEND.
           if  MESSAGE-TEXT not = SPACES
               move MESSAGE-TEXT to STD-MESSAGE-TEXT
               perform Z-POST-MESSAGE
           end-if
           move 'Program is ABENDING...' to MESSAGE-TEXT
           perform Z-POST-MESSAGE
           perform Z-POST-CONSOLE
           add 16 to ZERO giving STD-RESPONSE
           GOBACK.

       Z-POST-COPYRIGHT.
           display SIM-TITLE     upon console
           display SIM-COPYRIGHT upon console
           exit.

       Z-POST-CONSOLE.
           display MESSAGE-BUFFER upon console
           exit.

       Z-POST-MESSAGE.
           display MESSAGE-BUFFER upon console
           move SPACES to MESSAGE-TEXT
           exit.

       Z-POST-CONDITIONAL-TRACE.
           if  STD-DEBUG-INFO = 'DEBUG   '
           or  STD-DEBUG-INFO = 'TRACE   '
               display MESSAGE-BUFFER upon console
           end-if
           move SPACES to MESSAGE-TEXT
           exit.
      *****************************************************************
      *      This example is provided by SimoTime Technologies        *
      *        Our e-mail address is: helpdesk@simotime.com           *
      *     Also, visit our Web Site at http://www.simotime.com       *
      *****************************************************************

Table of Contents Previous Section Next Section Summary

This suite of programs provides an example of various routines that edit, validate, format or convert dates. This document may be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Technologies.

SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software, documentation or training material.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Note: The latest versions of the SimoTime Documents and Program Suites are available on the Internet and may be accessed using the Link to Internet icon. If a user has a SimoTime Enterprise License the Documents and Program Suites may be available on a local server and accessed using the Link to Server icon.

Link to Internet   Link to Server   Explore How to Determine the Difference in Two Dates with the difference being calcualted in days.

Link to Internet   Link to Server   Explore the COBOL Connection for more examples of COBOL programming techniques and sample code.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Comments or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com


Return-to-Top
Date Processing Examples
Copyright © 1987-2024
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com