[Pharo-project] Odd TimeStamp from string issue
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
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 <patmaddox@me.com>:
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 <nicolas.cellier.aka.nice@gmail.com>:
2011/9/27 Pat Maddox <patmaddox@me.com>:
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
On Tue, Sep 27, 2011 at 2:04 PM, Pat Maddox <patmaddox@me.com> 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 <patmaddox@me.com> 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
+1 On Sep 27, 2011, at 11:35 PM, Chris Cunningham wrote:
On Tue, Sep 27, 2011 at 2:04 PM, Pat Maddox <patmaddox@me.com> 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
participants (5)
-
Chris Cunningham -
csrabak@bol.com.br -
Nicolas Cellier -
Pat Maddox -
Stéphane Ducasse