[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Julian Days and Date Conversions?

» close window

The Question is:

 
We have discovered an old fortran routine that was performing  date
conversions from yymmdd to yyddd and yyddd to yymmdd.  The conversion was
referred to as Julian date.  The source for this program seems to be long
gone.
 
After reading through the FAQ's it appears that the format yyddd is not a
true julian date.  Before rewriting these programs to add the century, I
wanted to know if there is a lib$ function that vms has to perform these
conversions.
 
Thanks
 
 


The Answer is :

 
  The Julian Date is generally a five-digit representation of the date,
  such as YYDDD.  The use of this format can cause obvious Year 2000
  readiness problems when Year 2000 concern.  For instance, if this
  was used as an RMS indexed file key, events the original programmer
  might not have anticipated (or at least did not completely plan for)
  could potentially arise.
 
  Astronomers also use a "Julian Day" concept, counting the number
  of days since Julian Day 1 began at 12:00 noon, on January 1, 4713
  BC.  (Presumably at Noon at Greenwich, England.)  The OpenVMS base
  date is based on this latter mechanism, as November 17th, 1858 is a
  nice, round value of 2,400,000 days since that January day back in
  4713 BC.  (For further details of this, see the HELP in DECwindows
  Calendar.)
 
  As for that indexed file key, consider changing the indexed file key
  over to a segmented key, or replacing it with the astronomer's version
  of Julian days, or replacing it with the OpenVMS Quadword format, or
  with a text "comparision" format derived from the OpenVMS or UTC time.
 
  There is no direct OpenVMS conversion to or from the Julian date
  "YYDDD" format, though this conversion is easily assembled from
  other existing calls.
 
  The relevent OpenVMS library calls are:
 
    LIB$DAY()
 
    LIB$CVT_FROM_INTERNAL_TIME(LIB$K_DAY_OF_YEAR,...)
 
    LIB$CVT_FROM_INTERNAL_TIME(LIB$K_JULIAN_DATE,...)
 
    LIB$CVT_TO_INTERNAL_TIME()
 
  The LIB$DAY call returns the number of days since the system base date
  of November 17th, 1858, while the LIB$CVT_FROM_INTERNAL_TIME itemcode
  LIB$K_JULIAN_DATE returns the number of days since January 1st of the
  current year.
 
  Using these and related calls, converting among various date formats
  should be quite easy.
 
  For an example of converting from a Julian date (YYMMM or YYYYDDD) to
  example, consider the following sequence.
 
    o First, call:
 
        LIB$CVT_TO_INTERNAL_TIME(LIB$K_DELTA_DAYS,...)
 
      to convert day portion of the Julian date to a delta time.
 
    o Then call:
 
        SYS$BINTIM()
 
      to convert the year to an absolute time.
 
    o Then add these quadwords together with a call to:
 
        LIB$ADD_TIMES()
 
  Specific information and algorithms for converting from a Gregorian date
  to a Julian day and from Julian to Gregorian are also available in the
  "Collected Algorithms from the Association for Computing Machinery (ACM)',
  among other resources.
 

answer written or last revised on ( 25-AUG-1999 )

» close window