r/ProgrammerHumor • • May 16 '20

The meaning of everything

Post image
35.0k Upvotes

533 comments sorted by

View all comments

Show parent comments

343

u/tinydonuts May 16 '20

Someone argued with me in another thread that dates and times are dead simple.

476

u/YourMJK May 16 '20

Well, depends on what abstraction level you are working on.
If you're only working with a date & time library (like you should!) instead of trying to do everything yourself, it's actually often not that complicated for the programmer.

The actual topic however is very complex and nuanced. That's why "you look at the people who dealt with this before and you thank them very much, you take what they made and put it in your program and you never ever look at it again. Because that way lies madness."

190

u/simulatedsausage May 16 '20

Spot on. Date and time are very, very tricky but luckily some big brained folks already figured out the hard parts and we can just use the libraries.

67

u/larhorse May 16 '20

I can tell you, as a dev who works with Dates and Times as the primary product - Those libraries also still have bugs. They're just more likely to be smaller edge cases.

Ex: Brazil decided not to change clocks again for DST in 2019. And we had Newfoundland clocks as an hour off - but no one noticed because the total pop is only about 500k and we had just a single customer in the area.

0

u/[deleted] May 16 '20

[deleted]

7

u/figuresys May 16 '20

Or they have basic date usage. As soon as you get into calculations, especially if you have to link that with a UI, you're gonna have tens of QA issues listed.

→ More replies (1)

18

u/JayTurnr May 16 '20

Another reason to use version management for your libraries so you keep your datetime libraries on the latest patch.

48

u/tinydonuts May 16 '20

That exact video is what sparked the argument.

36

u/RedditorBe May 16 '20

Did they not watch it? Heh

40

u/hahahahastayingalive May 16 '20

Having a library doesn’t mean you’re done with it though.

It just means you’re set a dam between you and the complexity, and the day the dam inevitably cracks or overflows you’re still getting wet, very wet.

Either you flee from area to area so that you’re never there when the dams cracks, or you fix dams so often that you effectively became a dam engineer and you ended up internalizing all the complexity and spend your free time swimming on the other side.

8

u/thoeoe May 16 '20

yeah, whoever said UTC was less hastle wasn't taking into account humans penchant for wanting illogical things.

We store date times in UTC, but spoiler alert, the offset from UTC is different depending on if you are in DST right now or not, and while it's technically correct, users got mad that the datediff between two date times both at noon 6 months apart return 182 days and one hour instead of exactly 182 days, because it was considered "too much work" to store the offset at the time of storage, we wrote our own method to convert to UTC ignoring DST

6

u/hahahahastayingalive May 16 '20

Yes!

At a point we made sure to have fancy pants library parsing and restoring every flavor of 8601 and most common formats, to store them in plain UTC in DB.

Then we realized one of the older system had everything fixed in UTC+2 ignoring DST. Then another system handled DST, but with an outdated database.

Then when we had most issues sorted, it was deemed reliable and we got a request to trigger a reminder 15min before a given event on the client app. Long story short, we basically reinvented NTP just to deal with the lag and funky settings. Never again.

4

u/kupiakos May 16 '20

That's why you have names for timezones like America/Los_Angeles rather than UTC-7 or PDT. That way your timezone library can convert between civil time (what's on a clock) and absolute time (no ambiguities) even over these complicated scenarios.

→ More replies (1)

9

u/[deleted] May 16 '20

Thank you for the link. I'm just getting into coding, finishing up CS50 right now. And damn, I haven't laughed that hard in a while. It was nice watching the video knowing it would end with that quote!

→ More replies (3)

85

u/parceriwafer May 16 '20

Probably hasn't dealed with them enough

31

u/Muhznit May 16 '20 edited May 16 '20

They aren't. Want proof? Try writing an algorithm that will tell you when easter occurs for a given year.

EDIT: I hadn't expected people to jump up to the challenge, but the amount of people starting their solutions with "Given ____..." kind of hints at how non-straightforward it is.

35

u/tinydonuts May 16 '20

Oh I know they're not. The other dude thought so though... JuSt UsE a LiBrArY.

29

u/MokitTheOmniscient May 16 '20

I guess it's not hard if someone else does it for you.

→ More replies (4)

20

u/[deleted] May 16 '20

[removed] — view removed comment

30

u/AegisToast May 16 '20

“year is undefined”

5

u/WilliamMButtlickerJr May 16 '20

Found the JavaScript programmer that makes comments in python syntax so he won’t get found out

→ More replies (2)

9

u/EirIroh May 16 '20

Given dates of the equinox and full moon occurences, it’s pretty simple. Missing any of those, you suddenly have a much larger task.

9

u/Meshiest May 16 '20

Tried my hand at it using suncalc.js to calculate full moons from sun and moon positions and only got 89% success for 600 Easters from 1700-2299.

Please excuse the absolute garbage javascript, it's 2am for me.

source website

→ More replies (4)
→ More replies (4)
→ More replies (14)