this post was submitted on 01 Dec 2023
335 points (98.0% liked)

Programmer Humor

32571 readers
182 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

I know this isn't any kind of surprise, and yet, well...

you are viewing a single comment's thread
view the rest of the comments
[–] accidentalloris@lemmy.world 41 points 1 year ago (2 children)

Then there's my code, which didn't even survive the time change.

[–] jubilationtcornpone@sh.itjust.works 15 points 1 year ago (2 children)

In every project I've ever worked on, there's been somebody who must have been like, "HurDur Storing timestamps in UTC is for losers. Nyeaahh!"

And if I ever find that person, I'm going to get one of those foam pool noodles, and whack him/her over the head with it until I've successfully vented all my frustrations.

[–] humorlessrepost@lemmy.world 16 points 1 year ago

I just use a float between 0 and 1 with 0 being 1970 and 1 being the predicted heat death of the universe.

[–] 48954246@lemmy.world 3 points 1 year ago (1 children)

The only time using UTC breaks down is when any sort of time change gets involved.

If I say I want a reminder at 9am six months from now and you store that as UTC, a day light savings change will mean I get my reminder an hour early or late depending on where in the world I am

[–] projectmoon@lemm.ee 8 points 1 year ago (1 children)

But wouldn't you calculate the time in the future in the right time zone and then store it back as UTC?

[–] 48954246@lemmy.world 1 points 1 year ago (1 children)

It depends on the application.

I don't remember all the specifics but this is the blog post I refer to when this topic comes up

https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a-silver-bullet/

So TL;DR: there might be unexpected time zone rule changes in the future. The solution presented in the article is to store both UTC and local time, so the application can easily adjust itself if such change happens.

[–] ultratiem@lemmy.ca 3 points 1 year ago (1 children)

Your code made it to the time change!!?

[–] agent_flounder@lemmy.world 4 points 1 year ago

Same... The change from 12 to 1