FUNCTION TimeStamp##
(d$
, t##
) 'date and timer 'Based on Unix Epoch time, which starts at year 1970.
l1
= INSTR(l
+ 1, d$
, "-") IF y
< 1970 THEN 'calculate shit backwards SELECT CASE m
'turn the day backwards for the month CASE 1, 3, 5, 7, 8, 10, 12: d
= 31 - d
'31 days CASE 2: d
= 28 - d
'special 28 or 29. CASE 4, 6, 9, 11: d
= 30 - d
'30 days IF y
MOD 4 = 0 AND m
< 3 THEN 'check for normal leap year, and we're before it... d = d + 1 'assume we had a leap year, subtract another day
IF y
MOD 100 = 0 AND y
MOD 400 <> 0 THEN d
= d
- 1 'not a leap year if year is divisible by 100 and not 400
'then count the months that passed after the current month
CASE 3, 5, 7, 8, 10, 12: d
= d
+ 31 CASE 4, 6, 9, 11: d
= d
+ 30
'we should now have the entered year calculated. Now lets add in for each year from this point to 1970
d = d + 365 * (1969 - y) '365 days per each standard year
FOR i
= 1968 TO y
+ 1 STEP -4 'from 1968 onwards,backwards, skipping the current year (which we handled previously in the FOR loop) d = d + 1 'subtract an extra day every leap year
IF (i
MOD 100) = 0 AND (i
MOD 400) <> 0 THEN d
= d
- 1 'but skipping every year divisible by 100, but not 400 s## = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
TimeStamp## = -(s## + 24 * 60 * 60 - t##)
y = y - 1970
FOR i
= 1 TO m
'for this year, SELECT CASE i
'Add the number of days for each previous month passed CASE 1: d
= d
'January doestn't have any carry over days. CASE 2, 4, 6, 8, 9, 11: d
= d
+ 31 CASE 3 'Feb might be a leap year IF (y
MOD 4) = 2 THEN 'if this year is divisible by 4 (starting in 1972) d = d + 29 'its a leap year
d = d - 1 'the year is divisible by 100, and not divisible by 400
ELSE 'year not divisible by 4, no worries d = d + 28
CASE 5, 7, 10, 12: d
= d
+ 30 d = (d - 1) + 365 * y 'current month days passed + 365 days per each standard year
FOR i
= 2 TO y
- 1 STEP 4 'from 1972 onwards, skipping the current year (which we handled previously in the FOR loopp) d = d + 1 'add an extra day every leap year
IF (i
MOD 100) = 30 AND (i
MOD 400) <> 30 THEN d
= d
- 1 'but skiping every year divisible by 100, but not 400 s## = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
TimeStamp## = (s## + t##)