If I do understand the Factor code ymd>timestamp correctly uses gmt but timestamp>ymd uses local time. So in Germany in summer today dup timestamp>ymd ymd>timestamp time- duration>hours . prints -2 Does that mean there is a bug in timestamp>ymd ?
I my application I want to use date strings of the local time. So I am thinking about local time versions. To get words that are not very long I replaced ymd by YMD. timestamp>YMD forgets the gmt-offset and YMD>timestamp expects a local date string and makes a timestamp with timezone information like the words yesterday and today. ( YMD>timestamp replaces local-ymd>timestamp from yesterday ) USING: calendar calendar.format calendar.format.macros io.streams.string typed ; IN: localDateString TYPED: timestamp>YMD ( timestamp: timestamp -- str ) [ { YYYY "-" MM "-" DD } formatted ] with-string-writer ; : YMD>timestamp ( str -- timestamp ) [ read-ymd 0 0 0 gmt-offset-duration <timestamp> ] with-string-reader ; Now today >gmt "2014-08-31" YMD>timestamp time- duration>days . today "2014-08-31" YMD>timestamp time- duration>days . today dup timestamp>YMD YMD>timestamp time- duration>hours . print 4 4 0 respectively which is what I wanted. > Oh, I see -- you want to compare a date in local time with a date in > GMT without considering the timezone difference. > > Your solution seems okay, albeit a little complicated by trying to > undo the notion of timezones. Perhaps as you play with it a bit , > you might have some idea of improvements to the API. We were trying > to preserve timezone information as much as possible, so for example > as you convert a YMD to a timestamp, it assumes GMT. Later, as you > use it, the timezone is included for time differences and other words. ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk