* Revision 1.2  1999/01/04 08:14:55  jamie
* y2k bug in cduptm
*
      SUBROUTINE CDUPTM (IDATE, ITIME, IDATM, IRC)
*     ============================================
*
************************************************************************
*                                                                      *
*        SUBR. CDUPTM (IDATE*, ITIME*, IDATM, IRC*)                    *
*                                                                      *
*   Unpacks date and time from one word                                *
*                                                                      *
*   Arguments :                                                        *
*                                                                      *
*     IDATE    Date : 6 Decimal integer : YYMMDD                       *
*     ITIME    Time : 4 Decimal integer : HHMM                         *
*     IDATM    Packed date-time                                        *
*     IRC      Return Code (See below)                                 *
*                                                                      *
*   Called by <USER>, CDENFZ, CDFZUP, CDLKEY, CDPART, CDPURP           *
*   Modified from original DBUPTM 19/03/90 JDS                         *
*                                                                      *
*   Error Condition :                                                  *
*                                                                      *
*     IRC       =  0 : No error                                        *
*               = 93 : Illegal time                                    *
*                                                                      *
************************************************************************
*
* cdunit.inc
*
*
*     Units for output, errors, redirected output, loglevel
*
      COMMON/CDUNIT/LOUTCD,LPRTCD,LFILCD,LLOGCD
      INTEGER       LOUTCD,LPRTCD,LFILCD,LLOGCD
*
* ctmpak.inc
*
      PARAMETER       (MXSEC=61, MXMIN=61, MXHOU=25, MXDAY=32, MXMON=13)
      PARAMETER       (MXYEA=99)
      INTEGER         IDAYY(20), IDAYM(12,2)
      SAVE            IDAYY, IDAYM
      DATA            IDAYY / 366,  731, 1096, 1461, 1827, 2192, 2557,
     1                       2922, 3288, 3653, 4018, 4383, 4749, 5114,
     2                       5479, 5844, 6210, 6575, 6940, 7305/
      DATA            IDAYM / 0,  31,  59,  90, 120, 151, 181, 212, 243,
     1                      273, 304, 334,   0,  31,  60,  91, 121, 152,
     2                      182, 213, 244, 274, 305, 335/
*

*     ------------------------------------------------------------------
*
      IRC  = 0
      III  = IDATM
      IMIN = MOD(III,MXMIN)
      III  = (III-IMIN)/MXMIN
      IHOU = MOD(III,MXHOU)
      III  = (III-IHOU)/MXHOU
      IDAY = MOD(III,MXDAY)
      III  = (III-IDAY)/MXDAY
      IMON = MOD(III,MXMON)
      IYEA = (III-IMON)/MXMON
 
      IF((IYEA.GT.MXYEA) .OR. (IMON.GE.MXMON) .OR. (IDAY.GE.MXDAY) .OR.
     +   (IHOU.GE.MXHOU) .OR. (IMIN.GE.MXMIN)) THEN
         IF(LLOGCD.GE.2)
     +   PRINT *,'CDUPTM. Invalid PACKed time - IDATE/ITIME set to zero'
         IRC   = 93
         IDATE = 0
         ITIME = 0
      ENDIF
*
      IDATE = IDAY + 100*IMON + 10000*IYEA
      ITIME = IMIN + 100*IHOU
*                                                             END CDUPTM
      END
