3 ms·
Why can't opening hours be stored in UTC?
by icholy 3y ago
Why can't opening hours be stored in UTC?
- bilsbie 3y agoI guess it would change based on local time changes.
- pjot 3y agoSeems like the ideal way to store them to me!
- jomoho 3y agoEvery heard of daylight savings time (DST)?
- capableweb 3y agoCan be adjust client-side, or wherever you need to present it, rather than adjusting stored data.
- mulmen 3y agoThis is only sometimes true. Cases like opening hours and daily batch processing rely on local time. Persisting the values in UTC mean best case you are wrong half of the year and worst case all of it.
- capableweb 3y agoJust because you're storing the time in UTC doesnt mean you can't also store the timezone, and lots of other related data too.
- mulmen 3y ago6am in my time zone is two different times in UTC. Right now it is 14:00 UTC. But when DST starts it will be 13:00. So what UTC value do you insert into your database for the opening time of the coffee shop? And how do you convert? Yes, you can store additional information to decipher the meaning of a UTC time but why? Storing locale is good because sometimes you need to know where something is, such as when converting the local time to another zone. But you should avoid creating dependencies between these values because it makes using them individually harder. The coffee shop opens at 6am. That is an unambiguous fact. The coffee shop is in Seattle, WA. That is another unambiguous fact. If the time is in UTC then you need to know the date the time was set or store a dtc flag and then build some logic to convert. You can just feed local time+locale into any datetime library and get whatever you need. UTC is great for a lot of things. Such as recording when something happened. But local time has a place as well.
- RichieAHB 3y agoA store’s opening hours will probably remain 9am-5pm regardless of any time zone changes around it. If you run a bunch of stores across time zones you need to know where each store is and whether it’s summer or winter to work backwards to find out 9-5 in UTC.
- mulmen 3y agoThe coffee shop in my neighborhood is open from 6am to 2pm Pacific. We observe daylight saving time. The shop hours do not change. So, what UTC value do you store?
- deleted 3y ago[deleted]