[Coco] Free code jd
phillip taylor
ptaylor2446 at gmail.com
Sat May 20 12:22:14 EDT 2017
Here is some free code that converts the date for example 02/17/2017
to a julian date. This code runs under Os9.
PROCEDURE JD
PARAM TD:STRING[15] \ (* Pass todays date *)
DIM mm,dd,yy \(* Integer *)
DIM day(7):STRING
DIM JDate:REAL
DIM Leapyear:INTEGER
DIM ST1:STRING[60]
DIM DT$:String[20]
day(1)="Monday"
day(2)="Tuesday"
day(3)="Wednesday"
day(4)="Thursday"
day(5)="Friday"
day(6)="Saturday"
day(7)="Sunday"
PRINT CHR$(12)
tdate$=" / / "
cont$="Y"
daynumber=0
DT$ = TD
WHILE cont$="Y" DO
dt$ = TD
mm=VAL(MID$(DT$,1,2))
dd=VAL(MID$(DT$,4,2))
yy=VAL(MID$(DT$,9,2))
ST1="0312931303130313130313031"
IF mm<1 OR mm>12 AND dd<0 OR
dd>VAL(MID$("0312931303130313130313031",mm*2,2)) THEN
cont$="Y"
ELSE
IF mm=2 AND MOD(yy,4)<>0 AND dd>28 THEN
cont$="Y"
ELSE
cont$="N"
ENDIF
ENDIF
ENDWHILE
(* Set the leap year Flag *)
REM IF MOD(yy,4)=0 AND mm>2 THEN
IF MOD(yy,4) = 0 then
Leapyear=1
ELSE
Leapyear=0
ENDIF
mm=INT(mm-1)
tdate$="000303060811131619212426"
JDate=INT((yy-1)/4+mm*28+VAL(MID$(tdate$,mm*2+1,2))+yy*365+dd+Leapyear
)
daynumber=MOD(JDate,7)
PRINT JDate
REM PRINT "Today is "; day(daynumber); " "; DATE$
PRINT "There have been "; JDate; " days since 1-1-1900"
REM IF leapyear THEN
IF Leapyear=1 THEN
PRINT "It is leap year"
ELSE
PRINT "It is not leap year"
ENDIF
END
More information about the Coco
mailing list