I’ writing a program that stores opening hours for a store in a database time field and was wondering what the correct time range would be, if I want to express that on a particular day the store is open 24 hours. Is it 0:00-23:59 ? Or is it 0:01-0:00 ? Both formats have a one-minute gap where the store is closed. Is it 0:00-0:00?
Are there locale-dependent differences on when a day starts?
I’ writing a program that stores opening hours for a store in a database
Share
The condition itself doesn’t really fit into your storage concept, but since you’ve got many invalid values for what you’re accomplishing (end < start, end == start) there’s nothing wrong with nominating any one of them. So, for instance, use 0:00 – 0:00 and mentally decide that end > start and therefore this must represent a full day. 0:00 – 23:59 has a legitimate meaning so I would avoid that one.
Another option would be to use start time + length rather than two times. I think I would choose this one for preference.
I think the start-of-day is irrelevant; if you keep your datastore and presentation layers independent then you can localise in your presentation layer (i.e. when printing the time) and the datastore won’t care when the day starts (so use UTC or store the timezone).
A point to note on implementation: you lack any means for a shop to open twice a day (e.g. lunch hour) or more.