}
} ;
-HELP: >local
+HELP: >local-time
{ $values { "timestamp" timestamp } }
{ $description "Converts the " { $snippet "timestamp" } " to the timezone of your computer." }
{ $examples
{ $example "USING: accessors calendar kernel prettyprint ;"
- "now now-gmt >local [ gmt-offset>> ] same? ."
+ "now now-gmt >local-time [ gmt-offset>> ] same? ."
"t"
}
} ;
}
} ;
-HELP: local
+HELP: local-time
{ $values { "timestamp" timestamp } }
{ $description "Set the time zone to the computer's local timezone." }
-{ $notes "The time is not converted, if you want that then call " { $link >local } "." } ;
+{ $notes "The time is not converted, if you want that then call " { $link >local-time } "." } ;
HELP: gmt
{ $values { "timestamp" timestamp } }
{ $description "Set the time zone to GMT." }
{ $notes "The time is not converted, if you want that then call " { $link >gmt } "." } ;
-{ local >local gmt >gmt convert-timezone } related-words
+{ local-time >local-time gmt >gmt utc >utc convert-timezone } related-words
HELP: duration*
{ $values { "obj1" object } { "obj2" object } { "obj3" object } }
}
"Time zones:"
{ $subsections
- >local
+ >local-time
>gmt
+ >utc
convert-timezone
}
"Timestamps relative to each other:"
: gmt ( timestamp -- timestamp )
instant >>gmt-offset ; inline
-: local ( timestamp -- timestamp )
+: local-time ( timestamp -- timestamp )
gmt-offset-duration >>gmt-offset ; inline
: convert-timezone ( timestamp duration -- timestamp )
[ over gmt-offset>> time- (time+) ] [ >>gmt-offset ] bi ;
-: >local ( timestamp -- timestamp )
+: >local-time ( timestamp -- timestamp )
gmt-offset-duration convert-timezone ;
: >gmt ( timestamp -- timestamp )
instant convert-timezone ;
+ALIAS: utc gmt
+ALIAS: >utc >gmt
+
M: timestamp <=> [ clone >gmt tuple-slots ] compare ;
<PRIVATE
<PRIVATE
: (time-) ( timestamp timestamp -- n )
- [ clone >gmt ] bi@
- [ [ >date< julian-day-number ] bi@ - 86400 * ] 2keep
- [ >time< [ [ 3600 * ] [ 60 * ] bi* ] dip + + ] bi@ - + ;
+ [ [ >date< julian-day-number ] bi@ - 86400 * ]
+ [ [ >time< [ 3600 * ] [ 60 * + ] [ + ] tri* ] bi@ - + ]
+ [ [ gmt-offset>> duration>seconds ] bi@ swap - + ] 2tri ;
PRIVATE>
{ FILETIME FILETIME FILETIME }
[ GetFileTime win32-error=0/f ]
with-out-parameters
- [ FILETIME>timestamp >local ] tri@
+ [ FILETIME>timestamp >local-time ] tri@
] with-destructors ;
: set-file-times ( path timestamp/f timestamp/f timestamp/f -- )