X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=basis%2Fcalendar%2Fcalendar.factor;h=7d65f99d21dbcc454340d253d20072bae8f357a2;hp=19af136e1b2fcd0d036773b45582482ef1888d8b;hb=fdf54cf0b11978ec300be74bfdfa4c75a71252ad;hpb=f6c83c6abf3ad4845466b0da857a71e802f67fd9 diff --git a/basis/calendar/calendar.factor b/basis/calendar/calendar.factor index 19af136e1b..7d65f99d21 100644 --- a/basis/calendar/calendar.factor +++ b/basis/calendar/calendar.factor @@ -311,35 +311,38 @@ DEFER: time- : convert-timezone ( timestamp duration -- timestamp ) [ over gmt-offset>> time- (time+) ] [ >>gmt-offset ] bi ; -: >local-time ( timestamp -- timestamp ) +: convert-local-time ( timestamp -- timestamp ) gmt-offset-duration convert-timezone ; -: >gmt ( timestamp -- timestamp ) +: convert-gmt ( timestamp -- timestamp ) instant convert-timezone ; -ALIAS: utc gmt -ALIAS: >utc >gmt +: >local-time ( timestamp -- timestamp' ) + clone convert-local-time ; -M: timestamp <=> [ clone >gmt tuple-slots ] compare ; +: >gmt ( timestamp -- timestamp' ) + clone convert-gmt ; -timezone ( timestamp duration -- timestamp' ) + [ clone ] [ convert-timezone ] bi* ; -: same-times? ( timestamp1 timestamp2 quot -- ? ) - [ clone >gmt ] prepose same? ; inline +ALIAS: utc gmt +ALIAS: convert-utc convert-gmt +ALIAS: >utc >gmt -PRIVATE> +M: timestamp <=> [ >gmt tuple-slots ] compare ; : same-year? ( ts1 ts2 -- ? ) - [ slots{ year } ] same-times? ; + [ >gmt slots{ year } ] same? ; : quarter ( timestamp -- [1,4] ) month>> 3 /i 1 + ; inline : same-quarter? ( ts1 ts2 -- ? ) - [ [ year>> ] [ quarter ] bi 2array ] same-times? ; + [ >gmt [ year>> ] [ quarter ] bi 2array ] same? ; : same-month? ( ts1 ts2 -- ? ) - [ slots{ year month } ] same-times? ; + [ >gmt slots{ year month } ] same? ; :: (day-of-year) ( year month day -- n ) month days-until nth day + { @@ -351,7 +354,7 @@ PRIVATE> >date< (day-of-year) ; : same-day? ( ts1 ts2 -- ? ) - [ slots{ year month day } ] same-times? ; + [ >gmt slots{ year month day } ] same? ; : (day-of-week) ( year month day -- n ) ! Zeller Congruence @@ -379,16 +382,16 @@ DEFER: end-of-year } case ; : same-week? ( ts1 ts2 -- ? ) - [ [ year>> ] [ week-number ] bi 2array ] same-times? ; + [ >gmt [ year>> ] [ week-number ] bi 2array ] same? ; : same-hour? ( ts1 ts2 -- ? ) - [ slots{ year month day hour } ] same-times? ; + [ >gmt slots{ year month day hour } ] same? ; : same-minute? ( ts1 ts2 -- ? ) - [ slots{ year month day hour minute } ] same-times? ; + [ >gmt slots{ year month day hour minute } ] same? ; : same-second? ( ts1 ts2 -- ? ) - [ slots{ year month day hour minute second } ] same-times? ; + [ >gmt slots{ year month day hour minute second } ] same? ;