Hi. This behavior tricked me and I'm curious if this is inteded or
not. If you take a timestamp from a string, and the hour is 24:00:00, then it will assume that the time is at the beginning of the day, that is, 23+ hours before the timestamp that starts at 23:59:59. TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' I would have hoped that would either be the end of the day, or the begining of the next one. So, is this expected behaviour? Thanks, Chris |
Looks strange to me.
Stef On Sep 27, 2011, at 10:47 PM, Chris Cunningham wrote: > Hi. This behavior tricked me and I'm curious if this is inteded or > not. If you take a timestamp from a string, and the hour is 24:00:00, > then it will assume that the time is at the beginning of the day, that > is, 23+ hours before the timestamp that starts at 23:59:59. > > TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' > > I would have hoped that would either be the end of the day, or the > begining of the next one. > > So, is this expected behaviour? > > Thanks, > Chris > |
In reply to this post by cbc
I don't think that's a valid timestamp. From http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight
The 24-hour clock notation avoids all of those ambiguities by using 00:00 for midnight at the start of the day and 12:00 for noon. From 23:59:59 the time shifts (one second later) to 00:00:00, the beginning of the next day. In 24-hour notation 24:00 can be used to refer to midnight at the end of a day. Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? Pat On Sep 27, 2011, at 1:47 PM, Chris Cunningham wrote: > Hi. This behavior tricked me and I'm curious if this is inteded or > not. If you take a timestamp from a string, and the hour is 24:00:00, > then it will assume that the time is at the beginning of the day, that > is, 23+ hours before the timestamp that starts at 23:59:59. > > TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' > > I would have hoped that would either be the end of the day, or the > begining of the next one. > > So, is this expected behaviour? > > Thanks, > Chris > |
2011/9/27 Pat Maddox <[hidden email]>:
> I don't think that's a valid timestamp. From http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight > > The 24-hour clock notation avoids all of those ambiguities by using 00:00 for midnight at the start of the day and 12:00 for noon. From 23:59:59 the time shifts (one second later) to 00:00:00, the beginning of the next day. In 24-hour notation 24:00 can be used to refer to midnight at the end of a day. > > Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? > > Pat > Hmm some days have leap seconds in UTC adjustments http://en.wikipedia.org/wiki/Leap_second , so beware... Nicolas > > On Sep 27, 2011, at 1:47 PM, Chris Cunningham wrote: > >> Hi. This behavior tricked me and I'm curious if this is inteded or >> not. If you take a timestamp from a string, and the hour is 24:00:00, >> then it will assume that the time is at the beginning of the day, that >> is, 23+ hours before the timestamp that starts at 23:59:59. >> >> TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' >> >> I would have hoped that would either be the end of the day, or the >> begining of the next one. >> >> So, is this expected behaviour? >> >> Thanks, >> Chris >> > > > |
2011/9/27 Nicolas Cellier <[hidden email]>:
> 2011/9/27 Pat Maddox <[hidden email]>: >> I don't think that's a valid timestamp. From http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight >> >> The 24-hour clock notation avoids all of those ambiguities by using 00:00 for midnight at the start of the day and 12:00 for noon. From 23:59:59 the time shifts (one second later) to 00:00:00, the beginning of the next day. In 24-hour notation 24:00 can be used to refer to midnight at the end of a day. >> >> Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? >> >> Pat >> > > Hmm some days have leap seconds in UTC adjustments > http://en.wikipedia.org/wiki/Leap_second , so beware... > > Nicolas > However, it is 23:59:60 UTC rather than 24:00:01 Nicolas >> >> On Sep 27, 2011, at 1:47 PM, Chris Cunningham wrote: >> >>> Hi. This behavior tricked me and I'm curious if this is inteded or >>> not. If you take a timestamp from a string, and the hour is 24:00:00, >>> then it will assume that the time is at the beginning of the day, that >>> is, 23+ hours before the timestamp that starts at 23:59:59. >>> >>> TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' >>> >>> I would have hoped that would either be the end of the day, or the >>> begining of the next one. >>> >>> So, is this expected behaviour? >>> >>> Thanks, >>> Chris >>> >> >> >> > |
In reply to this post by patmaddox
On Tue, Sep 27, 2011 at 2:04 PM, Pat Maddox <[hidden email]> wrote:
> Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? TimeStamp fromString: '2011-09-27 24:00:01' -> '27 September 2011 12:00:01 am' As for contradictions (if it was from my message), this behavior is not expected by me, but it may be expected by the rest of the community (which is what I was asking about). It sounds like it isn't, though. I think the method is too permissive - it probably should have rejected my input as bad. The code path delegates the time portion off to Time, which delegates it off to Duration (with no bounds checks), then asks for the seconds and nanos back from Duration via #ticks, which hides the fact that a date boundary has been exceeded: days := self days. ^ Array with: days with: seconds - (days * SecondsInDay) with: nanos (the seconds - (days * SecondsInDay) part). -Chris |
On Sep 27, 2011, at 2:35 PM, Chris Cunningham wrote:
> On Tue, Sep 27, 2011 at 2:04 PM, Pat Maddox <[hidden email]> wrote: >> Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? > > TimeStamp fromString: '2011-09-27 24:00:01' -> '27 September 2011 12:00:01 am' > > As for contradictions (if it was from my message), this behavior is > not expected by me, but it may be expected by the rest of the > community (which is what I was asking about). It sounds like it > isn't, though. Sorry I was referring to wikipedia as potentially having sloppy writing, because the final sentence of the paragraph I quoted appeared to contract the first. I would also expect TimeStamp fromString: to raise an error instead of just accepting it. Pat |
In reply to this post by cbc
Chris,
I don't know if this is odd at all. In all clocks made to English speaking countries I've had chance to play with 12:00 am is midnight and 12:00 pm is noon. So the only thing TimeStamp seems (to me) to be doing is reformatting the string to twelve hour format. Not any 23+ hours before at all! my 0.019999999.....
--
Cesar Rabak
Em 27/09/2011 17:47, Chris Cunningham < [hidden email] > escreveu: Hi. This behavior tricked me and I'm curious if this is inteded or not. If you take a timestamp from a string, and the hour is 24:00:00, then it will assume that the time is at the beginning of the day, that is, 23+ hours before the timestamp that starts at 23:59:59. TimeStamp fromString: '2011-09-27 24:00:00' -> '27 September 2011 12:00 am' I would have hoped that would either be the end of the day, or the begining of the next one. So, is this expected behaviour? Thanks, Chris |
In reply to this post by cbc
+1
On Sep 27, 2011, at 11:35 PM, Chris Cunningham wrote: > On Tue, Sep 27, 2011 at 2:04 PM, Pat Maddox <[hidden email]> wrote: >> Might be sloppy writing because that last sentence seems to contradict the first one. At any rate, I wouldn't expect that to be valid. What is 24:00:01 ? > > TimeStamp fromString: '2011-09-27 24:00:01' -> '27 September 2011 12:00:01 am' > > As for contradictions (if it was from my message), this behavior is > not expected by me, but it may be expected by the rest of the > community (which is what I was asking about). It sounds like it > isn't, though. > > I think the method is too permissive - it probably should have > rejected my input as bad. > > The code path delegates the time portion off to Time, which delegates > it off to Duration (with no bounds checks), then asks for the seconds > and nanos back from Duration via #ticks, which hides the fact that a > date boundary has been exceeded: > > days := self days. > ^ Array > with: days > with: seconds - (days * SecondsInDay) > with: nanos > (the seconds - (days * SecondsInDay) part). > > -Chris > |
Free forum by Nabble | Edit this page |