


openconsole

string time,date
int h,m,s,d,mo,y,seconds,days

time = time$
date = date$

print

'Seconds from midnight
seconds = Secs()

'Date in Julian format
days = Julian(y,mo,d)


print " days ",days," seconds ",seconds
print
print " Press any key to end..."
print
waitcon
end

Sub Julian(year :int, month :int, day : int),int
def a, jn, m, y : int
a = (14 - month)/12
y = year + 4800 - a
m = month + 12 * a - 3
jn = day + (153 * m + 2)/5 + y * 365 + y/4 - y/100 + y/400 - 32045
RETURN jn
endsub 

sub Secs(),int
h = val(mid$(time,1,2))
m = val(mid$(time,4,2))
s = val(mid$(time,7,2))

d = val(mid$(date,1,2))
mo = val(mid$(date,4,2))
y = val(mid$(date,7,4))

'Seconds from midnight
seconds = h * 3600
seconds = seconds + (m * 60)
seconds = seconds + s

return seconds
endsub
