Recommended Reading

IDMS Journal DateStamp Conversions

DATESTAMP to Date from IDMS-L

The following is a simple method of converting DATESTAMP to date.
You can use IDMSLOOK. Take the eight-byte date/time stamp, in hex and pass it to IDMSLOOK:
E.G.
LOOK DATETIME STAMP=0164984BEFBAEEA1
(where 0164984BEFBAEEA1 is the eight byte hex date/time stamp from the journal)
This returns:
        DATETIME ---> 2000-07-06-13.34.51.716449
This works both online, and in batch.

Date to DATESTAMP

This code was written by Bill Blaney. The text below is his covering eMail.

From: Bill L. Blaney

Attached you will find the REXX exec I created to convert "real" date/time to journal timestamp format. I believe that it is commented well enough to follow the logic.

I originally created this exec as part of a ISPF application used by my clients to generate journal reports. It uses dialog manager to present the user with a list of available tape/disk journal archives and parameters to apply. It then verifies the parameters and generates the JCL to process the journal report. It makes use of dialog manager, has SPF messages and tutorial screens, and generates the JCL by using a skeleton library member. I found it a great exercise in learning how to make use of several ISPF features. If you think this may be of use to you (or to anyone else for that matter) let me know and I'll send you the rest of the application pieces as well.

By all means, feel free to post this or distribute as you will. Just remember to include a disclaimer (author not responsible for damages, blah, blah, blah). It was originally written for the U.S. Social Security Administration, and according to Federal Law is considered part of the public domain. (I believe the thinking is that since the citizens of the U.S. paid for it collectively through their taxes, it belongs to all of them.

Have fun,
Bill


IDMS Journal DateStamp Conversions

Bill's REXX for Date to DATESTAMP


/******************************* REXX *********************************/
/*   This exec is designed to convert a "real" date and time to its   */
/*   internal IDMS timestamp format.                                  */
/*                                                                    */
/*   Input:  date in mm/dd/yyyy format;                               */
/*           time in hh:mm:ss   format;                               */
/*                                                                    */
/*   Output: timestamp as an eight-character hex string (xxxxxxxx)    */
/*                                                                    */
/*   Special Considerations:                                          */
/*                                                                    */
/*     - No date/time validation is performed.  It is the caller's    */
/*       responsibility to ensure that a valid date and time have     */
/*       been passed;                                                 */
/*                                                                    */
/*     - Date must be after 01/01/1900;                               */
/*                                                                    */
/*     - Year must be four characters (e.g., 1998)                    */
/*                                                                    */
/*     - Month and day must be two characters (01, 02, ... etc);      */
/*                                                                    */
/*     - Year, month and day must be separated by slashes (/);        */
/*                                                                    */
/*     - Hours, minutes and seconds must be two characters;           */
/*                                                                    */
/*     - Hours, minutes and seconds must be separated by colons (:).  */
/*                                                                    */
/**********************************************************************/
arg date time .
/**********************************************************************/
/* split date and time into their individual components:              */
/**********************************************************************/
  parse var date month '/' day '/' year .
  parse var time hour  ':' min ':' sec  .
/**********************************************************************/
/* create table for converting date to julian:                        */
/**********************************************************************/
  month_offset.0  = 12
  month_offset.01 =   0
  month_offset.02 =  31
  month_offset.03 =  59
  month_offset.04 =  90
  month_offset.05 = 120
  month_offset.06 = 151
  month_offset.07 = 181
  month_offset.08 = 212
  month_offset.09 = 243
  month_offset.10 = 273
  month_offset.11 = 303
  month_offset.12 = 334
/**********************************************************************/
/* increase the size of numeric values to accommodate timestamp:      */
/**********************************************************************/
  numeric digits 18
/**********************************************************************/
/* convert the date to julian:                                        */
/**********************************************************************/
  nonleap_years = year // 4                /* number of years since   */
                                           /* last leap year          */
  julian_date = day + month_offset.month   /* julian date for date    */
  if nonleap_years = 0 & year > 1900       /* if this is a leap year  */
  then do                                  /* ... and the date is     */
     if month > 02                         /*     after February      */
     then do                               /* then                    */
        julian_date = julian_date + 1      /*     add 2/29 to date    */
     end
  end
/**********************************************************************/
/*  The IDMS timestamp records the date as the number of days elapsed */
/*  since 01/01/0001.  Since bizarre things happen when the date used */
/*  is prior to 1600 (implementation date of the current calendar),   */
/*  we compute the number of days elapsed between the passed date and */
/*  01/01/1900 and add to it the timestamp value for 01/01/1900.      */
/*                                                                    */
/*  In computing the days elapsed, we make use of an olympiad, which  */
/*  is a 4-year cycle made up of 1461 days (365*4 + 1 for leap year). */
/**********************************************************************/
  olympiads = (year - 1900) % 4    /* number of olympiads since 1900  */
  day_cnt = 693594 ,               /* elapsed days for 01/01/1900     */
          + olympiads*1461 ,       /* 4-year cycles since 01/01/1900  */
          + nonleap_years*365 ,    /* years since last leap year      */
          + julian_date            /* days since start of this year   */
/**********************************************************************/
/* if the year requested is a leap year, then the number of olympiads */
/* included a day for this year's 2/29.  This will throw our count    */
/* off by 1; since we've already accounted for 2/29 in julian_date    */
/* (if applicable).                                                   */
/**********************************************************************/
  if nonleap_years = 0 & year > 1900       /* if this is a leap year  */
     then day_cnt = day_cnt - 1    /* so remove extra 2/29            */
/**********************************************************************/
/* The timestamp stores the date as a 27 bit string.  Here we convert */
/* the days elapsed into that bit string.                             */
/**********************************************************************/
  day_hex = d2x(day_cnt,7)        /* convert date to hex string       */
  day_bin = x2b(day_hex)          /* convert date to binary string    */
  day_bin = substr(day_bin,2,27)  /* set up bitstring for date        */
/**********************************************************************/
/*  The IDMS timestamp records the time as the number of seconds      */
/*  elapsed since midnight.  Here we convert the time passed to       */
/*  that value.                                                       */
/**********************************************************************/
  sec_cnt = hour*3600 + min*60 + sec
/**********************************************************************/
/* The timestamp stores the time as a 17 bit string.  Here we convert */
/* the time into that bit string.                                     */
/**********************************************************************/
  sec_hex = d2x(sec_cnt,5)        /* convert time to hex string       */
  sec_bin = x2b(sec_hex)          /* convert time to bit string       */
  sec_bin = substr(sec_bin,4)     /* lop off first three bits         */
/**********************************************************************/
/* Now we build the bit string for full internal date.                */
/* It is composed as follows:                                         */
/*   bits  1 - 27   days elapsed since 01/01/0001;                    */
/*   bits 28 - 44   seconds elapsed since midnight;                   */
/*   bits 45 - 64   fractions of a second (set to 0);                 */
/* Once we put the bit string together, we convert the result to its  */
/* hexadecimal equivalent and return it to the caller.                */
/**********************************************************************/
  dts_bin = day_bin || sec_bin || '00000000000000000000'
  dts_hex = b2x(dts_bin)          /* convert the timestamp to hex     */
return dts_hex

Back to sample list



© Copyright IT Doctors.co.uk. 2002