|
INPUT PROMPT "(始)西暦 年、月、日、時、分、秒 :":YEAR1,MONTH1,DAY1,HOUR1,MINUTE1,SECOND1
INPUT PROMPT "(終)西暦 年、月、日、時、分、秒 :":YEAR2,MONTH2,DAY2,HOUR2,MINUTE2,SECOND2
LET L1=CALCDAY(YEAR1,MONTH1,DAY1)
LET L2=CALCDAY(YEAR2,MONTH2,DAY2)
LET T1=TOTALTIME(HOUR1,MINUTE1,SECOND1)
LET T2=TOTALTIME(HOUR2,MINUTE2,SECOND2)
LET L=L2-L1
LET T=T2-T1
IF T<0 THEN
LET L=L-1
LET T=T+86400
END IF
CALL CALCTIME(T,HOUR,MINUTE,SECOND)
CALL CALCYMD(INT(L+T/86400),YEAR1,MONTH1,GYEAR,GMONTH,GDAY)
!'CALL CALCYMD2(INT(L+T/86400),CYEAR,CMONTH,CDAY)
PRINT "西暦";YEAR1;"年";MONTH1;"月";DAY1;"日";HOUR1;"時";MINUTE1;"分";SECOND1;"秒から"
PRINT "西暦";YEAR2;"年";MONTH2;"月";DAY2;"日";HOUR2;"時";MINUTE2;"分";SECOND2;"秒までは"
PRINT GYEAR;"年";GMONTH;"ヶ月";GDAY;"日";HOUR;"時間";MINUTE;"分";SECOND;"秒"
!'PRINT CYEAR;"年";CMONTH;"ヶ月";CDAY;"日"
PRINT (L+T/86400)/365.2425;"年"
PRINT (L+T/86400)/(365.2425/12);"ヶ月"
PRINT (L+T/86400)/7;"週"
PRINT L+T/86400;"日"
PRINT L*24+T/3600;"時間"
PRINT L*24*60+T/60;"分"
PRINT L*86400+T;"秒"
END
EXTERNAL FUNCTION CALCDAY(Y,M,N)
DIM D(12),DD(12)
MAT READ D,DD
DATA 0,31,59,90,120,151,181,212,243,273,304,334
DATA 31,28,31,30,31,30,31,31,30,31,30,31
LET YL=Y-1
LET Z=365*YL+D(M)+N+INT(YL/4)+INT(YL/400)-INT(YL/100)
IF (MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0) AND M>2 THEN !'うるう年
LET Z=Z+1
END IF
LET CALCDAY=Z
END FUNCTION
EXTERNAL SUB CALCTIME(T,HOUR,MINUTE,SECOND)
LET HOUR=INT(T/3600)
LET TT=TT+HOUR*3600
LET MINUTE=INT((T-TT)/60)
LET TT=TT+MINUTE*60
LET SECOND=T-TT
END SUB
EXTERNAL FUNCTION TOTALTIME(HOUR,MINUTE,SECOND)
LET TOTALTIME=HOUR*3600+MINUTE*60+SECOND
END FUNCTION
EXTERNAL SUB CALCYMD2(L,YEAR,MONTH,DAY)
LET YEAR=INT(L/365.2425)
LET LL=LL+INT(365.2425*YEAR)
LET MONTH=INT((L-YEAR*365.2425)/(365.2425/12)+.4)
LET LL=LL+INT(MONTH*(365.2425/12))
LET DAY=L-LL
IF DAY<0 THEN LET DAY=0
END SUB
EXTERNAL SUB CALCYMD(LL,Y1,M1,YEAR,MONTH,DAY)
DIM DD(12)
MAT READ DD
DATA 31,28,31,30,31,30,31,31,30,31,30,31
LET L=LL
LET Y=Y1
LET M=M1
LET YEAR=0
LET MONTH=0
LET DAY=0
IF (MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0) AND M<3 THEN LET Z=1 ELSE LET Z=0
DO WHILE L-(365+Z)>=0
LET L=L-(365+Z)
LET YEAR=YEAR+1
LET Y=Y+1
IF (MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0) AND M<3 THEN LET Z=1 ELSE LET Z=0
LOOP
IF (MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0) AND M=2 THEN LET Z=1 ELSE LET Z=0
DO WHILE L-(DD(M)+Z)>=0
LET L=L-(DD(M)+Z)
LET MONTH=MONTH+1
LET M=M+1
IF M>12 THEN LET M=1
IF (MOD(Y,4)=0 AND MOD(Y,100)<>0 OR MOD(Y,400)=0) AND M=2 THEN LET Z=1 ELSE LET Z=0
LOOP
LET DAY=L-DAY
END SUB
※うるう年
4で割れる年はうるう年 2012年,2016年など
100で割れる年はうるう年ではない 1800年,1900年など
400で割れる年はうるう年 2000年など
400年間の日数
400*365+400/4-400/100+400/400=146097日 400年間にうるう年が97日
400年間の年平均日数 146097日/400年=365.2425日
|
|