A105@UWOCC1.BITNET (Brent Sterner) (03/03/86)
A note of thanks to everyone who replied. My primary concern was that I not overlook something really obvious. I hadn't. I received several algorithms, one which missed by a day. Someone suggested I repost to INFO-ASTRONOMY. One algorithm however was unique. It performs a binary search for the julian day. At the risk of prolonging this thing (I've seen enough unless someone has some really spiffy new fast algorithm) I'd like to make this available to everyone. Perhaps, like me, others will find the technique a new way to tackle a problem. I like having new doors opening to me. And a public thankyou to Ed Miller for sending me this. .......................................................................... ......................................................................... Date: 26 FEB 86 17:13-PST From: ESMP09%SLACTWGM.BITNET@ucbvax.berkeley.edu To: INFO-VAX@sri-kl.arpa Subject: Re: Julian date >> 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 $ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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)