Author(s): O. Hell | Library: KERNLIB |
Submitter: | Submitted: 27.11. 1984 |
Language: Fortran | Revised: |
CALDAT converts any calendar date represention in a set of such representations to all other calendar date representations in the set; in addition a few extra bits of information are produced.
Structure:
SUBROUTINE subprogram
User Entry Names: CALDAT
Internal Entry Names: CDMON, CLEAP, CYDIY,
CYEARY
External References: DATIME
Usage:
CALL CALDAT(IINDEX,CHREP,IBNREP,IERR)
CHARACTER DMY14*14,DMY11*11,DMY9*9,DMY10*10 CHARACTER*8 DMY8A,DMY8B,YMD8,MDY8,YDM8 CHARACTER*6 DMY6, YMD6,MDY6,YDM6 CHARACTER YD5*5,W4*4,W2*2 EQUIVALENCE * (CHREP( 1: 14), DMY14), (CHREP( 15: 25), DMY11), * (CHREP( 26: 34), DMY9 ), (CHREP( 35: 44), DMY10), * (CHREP( 45: 52), DMY8A), (CHREP( 53: 60), DMY8B), * (CHREP( 61: 66), DMY6 ), (CHREP( 67: 74), YMD8 ), * (CHREP( 75: 80), YMD6 ), (CHREP( 81: 88), MDY8 ), * (CHREP( 89: 94), MDY6 ), (CHREP( 95:102), YDM8 ), * (CHREP(103:108), YDM6 ), (CHREP(109:113), YD5 ), * (CHREP(114:117), W4 ), (CHREP(118:119), W2 )
Details of the substrings in argument CHREP and the corresponding IINDEX values:
EXAMPLE IINDEX EXAMPLE IINDEX DMY14 16. APRIL 1982 1 YMD6 820416 9 DMY11 16 APR 1982 2 MDY8 04/16/82 10 DMY9 16 APR 82 3 MDY6 041682 11 DMY10 16. 4.1982 4 YDM8 82/16/04 12 DMY8A 16. 4.82 5 YDM6 821604 13 DMY8B 16/04/82 6 YD5 82106 14 DMY6 160482 7 W4 FRI. YMD8 82/04/16 8 W2 FRDetails of the elements in argument IBNREP and the corresponding IINDEX values:
Element Contents Type Example IINDEX 1,2,3 d, m, y binary 16, 4, 1982 101 4 day in the year binary 106 102 5 00YYDDDC packed dec 0082106C 103 6 Julian date binary 723651 104 7 weekday, MO=0,... binary 4 8 week in the year binary 15 3,4 y, day in year binary 1982, 106 105Notes: Julian date = days since 1/1/1, without Gregory's pause. Week 1 of the year contains the 1st Thursday in the year (ISO).
'JAN', | 'FEB', | 'MAR', | 'APR', | 'MAY', | 'JUN', |
'JUL', | 'AUG', | 'SEP', | 'OCT', | 'NOV', | 'DEC' |
'JAN. ', | 'FEB. ', | 'MARCH', | 'APRIL', | 'MAY ', | 'JUNE ', |
'JULY ', | 'AUG. ', | 'SEPT.', | 'OCT. ', | 'NOV. ', | 'DEC. ' |
Method:
Two arguments are used for passing the calendar dates: a character string and an array of full words. The various representations are numbered, and an input parameter ('input index') specifies the representation containing the input calendar date.
An extra output parameter receives a return code.
Special cases:
Restrictions:
CALDAT will give incorrect dates and weekdays for dates prior to the reformation of the Calendar by pope Gregory (16th century).
Error handling:
IERR | Meaning | |
0 | everything fine | |
4 | ||
8 | upper bound for lower bound for IBNREP | |
12 | upper bound for | |
16 | ddd out of bounds | |
20 | mm | dd out of bounds | |
24 | yyyy out of bounds |
IERR in IINDEX IERR in IINDEX IERR in IINDEX 1001 DMY14 1 1006 DMY8B 6 1011 MDY6 11 1002 DMY11 2 1007 DMY6 7 1012 YDM8 12 1003 DMY9 3 1008 YMD8 8 1013 YDM6 13 1004 DMY10 4 1009 YMD6 9 1014 YD5 14 1005 DMY8A 5 1010 MDY8 10 1103 Julian 103
Notes:
Element 5 of IBNREP is not a Fortran type. Nevertheless this calendar date format may show up in data from the 'real world'. Element 7 of IBNREP is especially well suited for arithmetical calculations with dates.
Examples:
C Initialize substring CHREP(15:25) DMY11='16 APR 1982' C Define this substring to be the input format IINDEX=2 CALL CALDAT(IINDEX,CHREP,IBNREP,IERR)