Re: [Factor-talk] how to calculate count of days

2014-09-07 Thread mr wzrd
Wondering how the date vs datetime distinction, and other distinctions regarding time, play out in Factor with HTML5. http://www.w3schools.com/html/html5_form_input_types.asp - mrw On 09/05/2014 12:34 PM, Jon Harper wrote: On Fri, Sep 5, 2014 at 6:19 PM, Alex Vondrak ajvond...@gmail.com

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Alex Vondrak
English is not my native language but could days-since be better? Just wanted to chime in here that `days-since` would be the perfect name (as in `2014-08-21 days-since`). English is my native language and I hadn't even thought of this name! :) On Wed, Sep 3, 2014 at 1:22 AM, Georg Simon

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Alex Vondrak
On Thu, Sep 4, 2014 at 4:06 PM, Jon Harper jon.harpe...@gmail.com wrote: How about: : today ( -- timestamp ) now midnight instant gmt-offset ; inline Or really just : today ( -- timestamp ) gmt midnight ; inline if I'm not mistaken. It's a short trip from `today`'s current definition:

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Jon Harper
On Fri, Sep 5, 2014 at 9:52 AM, Alex Vondrak ajvond...@gmail.com wrote: On Thu, Sep 4, 2014 at 4:06 PM, Jon Harper jon.harpe...@gmail.com wrote: How about: : today ( -- timestamp ) now midnight instant gmt-offset ; inline Or really just : today ( -- timestamp ) gmt midnight ; inline

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Georg Simon
But then things go wrong in the rare cases when you change your timezone. I have learned much and now use two new words which solve my problem: : local-ymdtimestamp ( str -- timestamp ) ! str is -MM-DD ymdtimestamp gmt-offset-duration gmt-offset ; : days-since ( str -- n ) ! str

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Alex Vondrak
On Fri, Sep 5, 2014 at 3:34 AM, Jon Harper jon.harpe...@gmail.com wrote: On Fri, Sep 5, 2014 at 9:52 AM, Alex Vondrak ajvond...@gmail.com wrote: On Thu, Sep 4, 2014 at 4:06 PM, Jon Harper jon.harpe...@gmail.com wrote: How about: : today ( -- timestamp ) now midnight instant gmt-offset ;

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Alex Vondrak
I also realize now that this date vs datetime distinction was what Jon was suggesting, whereas I thought he was talking about have one version normalize to local time, have the other normalize to GMT (like Date.current Date.today in Rails). I'm all for a date vs datetime distinction---probably

Re: [Factor-talk] how to calculate count of days

2014-09-05 Thread Jon Harper
On Fri, Sep 5, 2014 at 6:19 PM, Alex Vondrak ajvond...@gmail.com wrote: I also realize now that this date vs datetime distinction was what Jon was suggesting, whereas I thought he was talking about have one version normalize to local time, have the other normalize to GMT (like Date.current

Re: [Factor-talk] how to calculate count of days

2014-09-04 Thread Georg Simon
today gmt 2014-08-31 ymdtimestamp time- durationdays . today 2014-08-31 ymdtimestamp time- durationdays . today in Germany both printed 3+11/12 Perhaps simpler would be just converting to GMT first: today gmt 2014-08-31 ymdtimestamp time- durationdays

Re: [Factor-talk] how to calculate count of days

2014-09-04 Thread John Benediktsson
I think timestampymd just ignores the timezone information, and should produce the same output (in fact I think implemented the exact same way) as your timestampYMD. On Thu, Sep 4, 2014 at 9:44 AM, Georg Simon georg.si...@auge.de wrote: If I do understand the Factor code ymdtimestamp

Re: [Factor-talk] how to calculate count of days

2014-09-04 Thread John Benediktsson
Hmm, I think you're effectively doing today (in local time) minus today (in GMT), which is something sorta like this: today dup clone 0 hours gmt-offset time- durationhours (this should output the number of hours from GMT in your local timezone) The time- word takes timezones into account,

Re: [Factor-talk] how to calculate count of days

2014-09-04 Thread Jon Harper
Georg's problem comes from the fact that ymdtimestamp represents a date by midnight gmt, whereas today represents it by midnight in the local timezone. The API should make it clear how we represent dates (ie whole days, which are not even the same 24 hours in different time zones) with timestamp

Re: [Factor-talk] how to calculate count of days

2014-09-03 Thread Georg Simon
Am Tue, 2 Sep 2014 19:09:45 -0700 schrieb Alex Vondrak ajvond...@gmail.com: Thank you. ... That is, if it weren't for the GMT bit, you could just say `2014-08-31 ymdtimestamp ago durationdays`. In fact, that would make a nice ymdword: `: days-ago ( timestamp -- days ) ago durationdays

Re: [Factor-talk] how to calculate count of days

2014-09-03 Thread John Benediktsson
Perhaps simpler would be just converting to GMT first: today gmt 2014-08-31 ymdtimestamp time- durationdays On Wed, Sep 3, 2014 at 1:22 AM, Georg Simon georg.si...@auge.de wrote: Am Tue, 2 Sep 2014 19:09:45 -0700 schrieb Alex Vondrak ajvond...@gmail.com: Thank you. ... That is, if

Re: [Factor-talk] how to calculate count of days

2014-09-03 Thread John Benediktsson
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

Re: [Factor-talk] how to calculate count of days

2014-09-02 Thread Alex Vondrak
I don't have Factor installed on this machine, so I can't test my suggestions. But I'll do my best. `today` is defined as `now midnight` - http://docs.factorcode.org/content/word-today,calendar.html Notice that `now` uses `gmt`, then sets the offset -