From 2073b376ca976551fcec092d827ae8ef3a0e85b9 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 25 Jul 2006 14:02:33 +0000 Subject: [PATCH] minor calendar fix --- contrib/calendar/calendar.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/calendar/calendar.factor b/contrib/calendar/calendar.factor index 83953810c7..e26f5af4c8 100644 --- a/contrib/calendar/calendar.factor +++ b/contrib/calendar/calendar.factor @@ -189,6 +189,7 @@ M: number +second ( timestamp n -- timestamp ) : timestamp>vec ( dt -- vec ) tuple>array 2 8 rot ; : dt>years ( dt -- x ) + #! Uses average month/year length since dt loses calendar data dt>vec [ 1 12 365.2425 8765.82 525949.2 31556952.0 ] [ / ] 2map sum ; : dt>months ( dt -- x ) dt>years 12 * ; : dt>days ( dt -- x ) dt>years 365.2425 * ; @@ -210,7 +211,8 @@ M: number +second ( timestamp n -- timestamp ) #! GMT time, right now 1970 1 1 0 0 0 0 millis 1000 /f seconds +dt ; -: timestamp- ( timestamp timestamp -- dt ) [ >gmt timestamp>vec ] 2apply v- ; +: timestamp- ( timestamp timestamp -- dt ) + [ >gmt timestamp>vec ] 2apply v- vec>dt ; : now ( -- timestamp ) gmt >local-time ; : before ( dt -- -dt ) dt>vec [ neg ] map vec>dt ;