Hacker News new | ask | show | jobs
by taylodl 1930 days ago
I work for a utility who often needs to work with interval data. The last interval of the day is 23:00-24:00 whereas the first interval of the day is 00:00-01:00. Some libraries can handle that as you'd expect, others can't. A lot of people are surprised to see 24:00. The key is 24:00 is the same date as 23:00, whereas 00:00 is the next day. It sounds like you have a similar need?
4 comments

In railway timetables things like 24:37 are sometimes used, for example for a train that leaves at 23:45 and arrives at 24:37 on weekdays. It would not just be confusing but totally incorrect to claim that the train arrives at 00:37 on weekdays. On the other hand, I don't think I've ever seen a 25:xx, and if you were writing a timetable for a slow train on the Trans-Siberian Railway then I really don't think people would appreciate it if you used a three-digit hour.
For what it's worth, some US train and bus timetables will totally write the arrival time as 00:37 or 12:37A. It's a localization thing.

For example, this Pacific Surfliner timetable [PDF] from Amtrack, where one train goes 11:36P -> 12:10A for one leg

https://www.amtrak.com/content/dam/projects/dotcom/english/p...

Here's a bus timetable [PDF] from Canada that goes 23:45 -> 00:00 -> 00:07: https://www.gotransit.com/static_files/gotransit/assets/pdf/...

24:37 is exactly what I'd call a hack.

It creatively abuses the lack of range checking in the format, and stretches the human facility of "knowing what I mean". It does not match a real time, though, because no clock shows this time as a current time.

While neat, it's a hack, a way to bend the notion of time, and as such, it ought to cause problems. Fortunately, airlines never seem to use this hack, and are able to indicate "00:37 next day".

I've seen 25:00 and even 26:00 being used as times, in Japan.
Yes they are common in Japan for stuff like store opening hours and TV time tables
I have also seen 24+ in Japan.
Times greater than 24:00 are not allowed by ISO 8601.

Looking at my copy of the draft of the 4th edition of ISO 8601, it seems they removed the 24:00 feature so now times have to be between 00:00 and 23:59. A shame, I think.

How would that be "totally incorrect"? There are only 24 hours in a day. It's incorrect to claim that there's 25, 26 or 27 hours in the day - even if it's useful and proper, it's not technically correct.
I'm making a guess here, but I think he means specifically the (A) "arrives every weekday at 00:37" part. That has a different implied meaning than (B) "the train arrives every weekday at 24:37." (A) implies that it will arrive every Monday through Friday mornings at 00:37 but will not arrive on Saturday or Sunday mornings at 00:37. (B) implies that it will arrive Tuesday through Saturday mornings at 00:37, but not Sunday or Monday mornings.

In the context of the train departure time, it's easy to work out what is meant by a weekday 00:37 arrival, but if they were divorced from each other for some reason, weekdays at 24:37 would be easier to interpret.

right - 24:37 friday makes is read as "37 past midnight on friday night" - which is friday night as humans consume time, but saturday morning by the calendar.

Being awake past midnight brings up a few challenges with calendars. My watch wil count a late (late) night walk against tomorrow, not against today. As a human, I consider "tomorrow" as "after I've gone to sleep", not "after midnight". 00:37 is still very much tonight.

An app I have to track habits and streaks lets you specify the time to count as "that day". I often walk my dog after midnight, so I have this set to 3am.
Think of it as a 24 hour day that starts at (to use UK public transport's setup) 4:30. You want the timetable and the users to agree on what 8am means, and that 8am and the following 2am are the same work day of 24 hours.
Google's GTFS spec, which is a spec for defining transit schedules among other things, allows for times greater than 24:00:00 to represent arrival and departure times on the following day for a given transit schedule.

https://developers.google.com/transit/gtfs/reference#stop_ti...

25:xx (and even 26:xx) are commonly used in Japan for TV programming to indicate that a segment is part of the previous day’s programme.
I did have to use 25:xx to log some late nights working at my last job in Japan. It was very weird to me, but that's how they wanted it. If it was part of the current workday, then it wouldn't reset to 0:00.
I have seen 26:xx and 27:xx on work. If we work (very) late, our work time system does write it like that.
Yep - we needed the distinction for a scheduling/rota app. Some users had shifts that started at 24:00 and then ended sometime during the night. Other users had shifts that ended at 24:00. I know that it's common to use 23:59 in the latter case, but IMO that's just a poor workaround; and I'd argue that 16:00 -> 00:00 is a lot less obvious than 16:00 -> 24:00.

As for a shift that starts friday 24:00, you could argue that the shift is actually a 'Saturday 00:00 shift', but the users didn't see it that way; they are scheduling Friday nights shifts and want an extra person late Friday evening.

When I used to work in a 24/7 environment I would quip that "it's not tomorrow until the morning crew takes over." In a lot of practical situations I think it's easier for people to think about the early morning hours as being late the previous day. It tends to match shifts and reporting cycles better.
It's not tomorrow until I've been to sleep. It's not the morning until I've had a cup of coffee. Time is incredibly subjective. Clocks need to agree, but nomenclature does not.
It's not really morning until the sun comes up ;-)
I had a software project where I thought I could infer which shift was working from the time (because shift-related metrics were really important). I learned very quickly that shift and time, though related, are really separate data points.
Part of the problem is that midnight doesn't have a date. But we pretend it does because that's much easier to program. Similarly, noon is neither A.M. nor P.M. but we pretend it is P.M. because that's easier to program. Both cases were very understandable compromises in the early days of computing but now we have both the processing power and storage to do things correctly but because of legacy inertia, we'll keep on going pretending things that aren't true are true.
Those intervals overlap. Does 00:00-01:00 _actually_ imply 00:00-00:59?

Also you're describing seems to be intervals, not datetime format.

edit: further:

This is directly from the RFC this thread is about:

Date and time expressions indicate an instant in time. Description of time periods, or intervals, is not covered here.

In practice the intervals don't overlap as they're understood as follows [23:00-24:00) and [00:00-01:00). That is the interval begins precisely at 23:00 or 00:00, but ends as close to the endpoint as your timing resolution allows. This way we don't have to write cumbersome expressions such as 23:00-23:59:59.999.