|
Here are two DCL routines to do what you want....
The first is Takes in a Julain Value,
the second takes a gregorian format.
I can't find the FORTRAN version....
$ Vfy = 'f$Verify(0)'
$!
$! This procedure converts a Julian day number (input in
$! P1) to the corresponding Gregorian calendar date
$! (output in In_Julian). The Gregorian date is assumed to
$! be in the 20th century.
$!
$ Months := "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
$!
$ Julian = 'P1'
$ Julian = Julian - 1721119
$ Year = (4 * Julian - 1 ) / 146097
$ Julian = 4 * Julian - 1 - 146097 * Year
$ Day = Julian / 4
$ Julian = ( 4 * Day + 3 ) / 1461
$ Day = 4 * Day + 3 - 1461 * Julian
$ Day = ( Day + 4 ) / 4
$ Month = ( 5 * Day - 3 ) / 153
$ Day = 5 * Day - 3 - 153 * Month
$ Day = (Day + 5 ) / 5
$ Year = 100 * Year + Julian
$ If(Month .ge. 10) Then Goto Else
$ Month = Month + 3
$ Goto Endif
$ Else:
$ Month = Month - 9
$ Year = Year + 1
$ Endif:
$!
$! Find the month
$!
$ M1 = (Month - 1 ) * 3
$ Mon := 'f$Extract(M1,3,Months)'
$ In_Julian:== 'Day'-'Mon'-'Year'
$ If Vfy Then Set Verify
----------------------------------------------------------------------------
$ Vfy = 'f$Verify(0)'
$!
$! This procedure converts a Gregorian calendar date (input
$! in P1) to the corresponding Julian day number (output
$! in P1). The Gregorian date is assumed to be in the
$! 20th century.
$!
$!
$! --- Initialization
$!
$ Months := "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
$!
$! Determine if users passed in a Date
$!
$ Time := 'f$Time()'
$ If p1 .nes. "" Then Time := 'P1'
$!
$! --- Get the current date from the system
$!
$ Hyphen = 'f$Locate("-",Time)'
$ Day = 'f$Extract(0,Hyphen,Time)
$ Hyphen = Hyphen + 1
$ Month_String := 'f$Extract(Hyphen,3,Time)'
$ Hyphen = Hyphen + 4
$ Year = 'F$Extract(Hyphen,4,Time)'
$!
$! Find the month and convert to an integer in the range 1 <--> 12
$!
$ Month = 1
$ Month_Loop:
$ Temp1 = (Month - 1 ) * 3
$ Temp_Month := 'f$Extract(Temp1,3,Months)'
$ If Temp_Month .eqs. Month_String Then Goto Got_Month
$ Month = Month + 1
$ Goto Month_Loop
$Got_Month:
$!
$! Now do the conversion from Gregorian to Julian date.
$!
$ If (Month .LE. 2) Then Goto Else
$ Month = Month - 3
$ Goto Endif
$ Else:
$ Month = Month + 9
$ Year = Year - 1
$ Endif:
$ C = Year / 100
$ Ya = Year - 100 * C
$ Out_Julian==(146097*C)/4+(1461*YA)/4+(153*MONTH+2)/5+DAY+1721119
$!
$! End of the OUTJULIAN command procedure.
$!
$ If vfy Then Set Verify
|