[mod.computers.vax] Julian date

A105@UWOCC1.BITNET (Brent Sterner) (02/24/86)

   I have an application that would like to determine the "Julian date"
in DCL (ie yyddd where ddd is the day of the year).  There is no lexical
function for this (or is there?).  Has anyone done this or have any ideas?

Brent Sterner
Computing & Communications Services
Natural Sciences Building
The University of Western Ontario
London, Ontario, Canada
N6A 5B7
Telephone (519)679-2151  (secretary)
                   2167  (direct)

CP.PAVER@MCC.ARPA (Bob Paver) (02/25/86)

>    I have an application that would like to determine the "Julian date"
> in DCL (ie yyddd where ddd is the day of the year).  There is no lexical
> function for this (or is there?).  Has anyone done this or have any ideas?

Enclosed you will find a short DCL procedure that calculates the day of
the week and the day of the year.  The algorithm is from collected
algorithms of the ACM which I've had lying around for years.  I haven't
tested the DCL thoroughly so use at your own risk.  It should at least
get you started.
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Bob Paver	(512) 834-3316
Microelectronics and Computer Technology Corp. (MCC)
9430 Research Blvd, Echelon Building #1
Austin, TX  78759-6509

ARPA:  paver@mcc.arpa
UUCP:  {ihnp4,seismo,harvard,gatech}!ut-sally!im4u!milano!paver

-----------  cut here ----------
$!
$!      DAYofYEAR.COM - Return the day of the week and the day
$!	                of the year.
$!
$!      Syntax:
$!
$!      $ @DAYOFYEAR
$!
$!----------------------------------------------------------
$!
$!      Get the date in all numeric format
$!
$ DATE = P1
$ IF P1 .EQS. "" THEN DATE = F$CVTIME(F$TIME())
$!
$!      Get the digits from DATE for each of YEAR, MONTH, and DAY.
$!      Note that F$EXTRACT sees the first character in a string
$!       as character 0.  We have the date as:
$!            yyyy-mm-dd hh:mm:ss.cc
$!            0123456789
$!
$ YEAR  = F$INTEGER(F$EXTRACT(0,4,DATE))
$ MONTH = F$INTEGER(F$EXTRACT(5,2,DATE))
$ DAY   = F$INTEGER(F$EXTRACT(8,2,DATE))
$!
$!      Compute day of week (N4 = 1-7: SUN-SAT)
$!
$ N1 = (13*(MONTH+10-(MONTH+10)/13*12)-1)/5+DAY+77 
$ N2 = N1+5*(YEAR+(MONTH-14)/12-(YEAR+(MONTH-14)/12)/100*100)/4
$ N3 = N2+(YEAR+(MONTH-14)/12)/400-(YEAR+(MONTH-14)/12)/100*2
$ N4 = N3 - (N3/7)*7 + 1
$!
$!	Compute day of year (D4 = 1-366)
$!
$ D1 = 3055*(MONTH+2)/100-(MONTH+10)/(13*2)-91 
$ D2 = (YEAR-YEAR/4*4+3)/4+(YEAR-YEAR/100*100+99)/100
$ D3 = (1-D2-(YEAR-YEAR/400*400+399)/400)*(MONTH+10)/13+DAY     
$ D4 = D1 + D3
$!
$ IF N4 .EQ. 1 THEN TODAY = "Sunday"
$ IF N4 .EQ. 2 THEN TODAY = "Monday"
$ IF N4 .EQ. 3 THEN TODAY = "Tuesday"
$ IF N4 .EQ. 4 THEN TODAY = "Wednesday"
$ IF N4 .EQ. 5 THEN TODAY = "Thursday"
$ IF N4 .EQ. 6 THEN TODAY = "Friday"
$ IF N4 .EQ. 7 THEN TODAY = "Saturday"
$!
$ WRITE SYS$OUTPUT "  Today is ",TODAY,"  Day = ",D4
-------

sasaki@HARVARD.HARVARD.EDU (Marty Sasaki) (02/26/86)

There are lots of programs to do Julian date (or Gregorian if you
prefer). I use the one published in the Collected Algoritms of CACM.
It would be a simple matter to do a lib$set_symbol to set a global
symbol value from within a program. You could then use it as any other
DCL symbol.

		Marty Sasaki

ESMP09@SLACTWGM.BITNET (03/01/86)

>>    I have an application that would like to determine the "Julian date"
>> in DCL (ie yyddd where ddd is the day of the year).  There is no lexical
>> function for this (or is there?).  Has anyone done this or have any ideas?

    The following code fragment illustrates a method of satisfying this
    need.

    Ed Miller
    ESMP09@SLACTWGM.BITNET

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$
$       NOW= F$CVTIME (,,"DATE")
$       LOW= 0
$       HIG= 366
$ LOOP:
$       CUR= (LOW+HIG)/2
$       TMP= F$CVTIME ("01-JAN+''CUR'-",,"DATE")
$       IF  TMP .EQS. NOW  THEN GOTO DONE
$       IF  TMP .GTS. NOW  THEN HIG= CUR-1
$       IF  TMP .LTS. NOW  THEN LOW= CUR+1
$       GOTO LOOP
$ DONE:
$       DAY_OF_YEAR= "00" + F$STRING (CUR+1)
$       DAY_OF_YEAR= F$EXTRACT (F$LENGTH (DAY_OF_YEAR)-3,3,DAY_OF_YEAR)
$       SHOW SYMBOL DAY_OF_YEAR
$
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -