this post was submitted on 03 Apr 2024
1093 points (96.2% liked)

Programmer Humor

18230 readers
1006 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 241 points 2 months ago (36 children)

I'm ok with timezones, but the guy who invented daylight savings time I'd slap to all the way to the sun

[–] [email protected] 17 points 2 months ago (7 children)

From a development perspective it certainly sounds easier to have one global timezone with DST than a bunch of smaller ones without it. Would that make sense in reality? Probably not but I definitely think timezones take more work to compensate for properly.

[–] fidodo 48 points 2 months ago (4 children)

What matters is consistency and our time system has tons of crazy inconsistent shit in our. Everyone knows about leap years, but do you know about leap seconds? Imagine trying to write a function to convert unix time to a current date and suddenly all your times are a second off.

Just look at this insane bullshit nonsense. The added complexity of time zones and daylight saving time is nothing compared to simply supporting our time system.

load more comments (4 replies)
load more comments (6 replies)
[–] scottywh 8 points 2 months ago (3 children)

Switching sucks but DST is better than Standard Time.

[–] [email protected] 12 points 2 months ago* (last edited 2 months ago) (4 children)

Which part of the year is DST and which part is Standard Time?

I know, but it seems like half the people that say they prefer DST have it backwards.

[–] scottywh 12 points 2 months ago (11 children)

It's easy, the good part is DST (which is what we're currently in - Spring through Fall in the northern hemisphere).

load more comments (11 replies)
load more comments (3 replies)
load more comments (2 replies)
load more comments (34 replies)
[–] [email protected] 80 points 2 months ago (3 children)

Worked on a project where devices just magically froze, but only during the month of February!

Turned out the people who had written the firmware had decided to do their own time math to save space and had put in an exception in the code for leap year values. Except instead of February 29th, it kicked in for the whole month. And the math was wrong so you ended up with negative values.

The product was due for launch in March of that year and was headed to manufacturing. It was by sheer luck that someone ran a test on February 1st and caught the problem.

Don't mess with time in code, kids.

[–] [email protected] 34 points 2 months ago (11 children)

This is why we have pre-built libraries and Unix time.

[–] [email protected] 18 points 2 months ago (1 children)

Embedded portable device with a teeny ARM processor. Sadly, no room for linux anything or even an RTC. Every time it connected to a phone, the phone would set its clock so the timestamps were somewhat close to being accurate.

However, if you swapped out the AAA battery and DIDN'T connect it to the phone at least once, all your subsequent readings would go back to zero epoch and would be forgotten 🤷🏻‍♂️

Good times.

[–] [email protected] 10 points 2 months ago (1 children)

Some absolute and utter legend of a man made a Unix kernel for the fucking ZILOG Z80, you have no excuses

(It's called UZI and it's written in K&R C for some obscure CP/M compiler)

[–] [email protected] 12 points 2 months ago (2 children)

If it had been up to me, I would have included a proper real-time-clock in the design and done things a lot differently.

But the device was designed by one company and the BLE and processor module by another. For some ungodly reason neither trusted each other, so nobody was given access to the firmware source on either side. I worked for a third company that was their customer paying the bill. I was allowed to see the firmware for both sides, but only read only, on laptops provided by each company, one at a time, in a conference room with their own people watching everything. Yeah, it was strange.

I was there because the MCU and the BLE processor sometimes glitched and introduced random noise. Turned out the connection between the two parts were unshielded UART with no error detection/correction 🤦🏻‍♂️

It was concidental that we hit the date glitch. Took all our effort just to get them to add a checksum and retry. The tiny MCU was maxed out of space. No way to fit in any more code for date math.

load more comments (2 replies)
load more comments (10 replies)
load more comments (2 replies)
[–] perviouslyiner 68 points 2 months ago (1 children)
[–] maniclucky 44 points 2 months ago
[–] someguy3 43 points 2 months ago* (last edited 2 months ago) (3 children)

Ok so there are 24 time zones. Before that every town had their own time based on the sun. We basically went from infinity time zones down to 24. This is in fact simpler.

(There are some half hour time zones too, (India, Newfoundland) so at least 26.)

[–] [email protected] 25 points 2 months ago (2 children)

There are a few time zones that are 45 minutes off, like Nepal Standard Time which is UTC+5:45, some places in Western Australia and South Australia use UTC+08:45 and the Chatham Islands are at UTC+12:45 or UTC+13:45 in summer.

load more comments (2 replies)
[–] perviouslyiner 10 points 2 months ago

there are 24 time zones

Cunningham's law says that this will generate some discussion in the replies!

load more comments (1 replies)
[–] [email protected] 35 points 2 months ago (2 children)

Soon we're going to have a new timezone for the moon. Yay, I guess?

[–] [email protected] 18 points 2 months ago (1 children)

Surely they will just use utc?

[–] [email protected] 27 points 2 months ago* (last edited 2 months ago) (1 children)

Can't be that simple due to time dilation effect. Time moves at a different rate in moon, about ~~1s~~ 58.7 μs difference per day.

https://www.reuters.com/science/white-house-directs-nasa-create-time-standard-moon-2024-04-02/

[–] davidgro 18 points 2 months ago (2 children)

That article says 58.7 microseconds per (Earth) day. Not 1s.

[–] [email protected] 11 points 2 months ago (1 children)

Shit you're right, I misremembered it.

[–] [email protected] 8 points 2 months ago* (last edited 2 months ago)

Appreciate you correcting your post, just one more needed.

ms = milliseconds

us = microseconds

load more comments (1 replies)
load more comments (1 replies)
[–] [email protected] 32 points 2 months ago (12 children)

not a programmer myself, but actually fuck you, UTC was the correct choice, anything that isn't UTC is a wrong choice, and i will literally fight to my death over this.

Timezones are dumb and stupid, and you cannot convince me otherwise, so far the single best argument i've heard is "well actually, the hands on a clock and the numbers themselves roughly represent the cycle of the sun in the sky during the day." Which is pretty good, until you realize that clocks tend to be circles, and you can often just rotate them. And suddenly, the numbers now match up perfectly. But i've also never once heard of someone caring about that specific feature, so uh. Good riddance frankly.

Timezones kind of made sense back in the day, when the sun was the only realistic timing system, and pre internet, when people stayed where they were. But now that people don't do that, and the internet tends to do this thing where it exists. I refuse to believe it makes more sense to have timezones than not.

"Hmmm yes please, i would like to order the time here, but halfway across the globe please" - statements dreamed up by the utterly insane.

ok that concludes my rant. Now i'm going to go set FUCKING DAYLIGHT SAVINGS TIME on my clock because FOR SOME REASON THE TIME JUST CHANGES HALFWAY THROUGH THE YEAR FUCK YOU.

load more comments (12 replies)
[–] brianorca 29 points 2 months ago

The guy that invented time zones was solving a problem where each little town had their own time standard. I don't think that was sustainable.

[–] technojamin 28 points 2 months ago (3 children)

I used to feel this way. Over the course of building out 2 calendar systems in my career (so far) and having to learn the intricacies of date and time-related data types and how they interact with time zones, I don’t have much disdain for time zones. I’d suggest for anyone who feels the same way as this meme read So You Want To Abolish Time Zones.

Also, programmers tend to get frustrated with time zones when they run into bugs around time zone conversion. This is almost always due to the code being written in a way that disregards the existence of times zones until it’s needed and then tacks on the time zone handling as an afterthought.

If any code that deals with time takes the full complexities of time zones into account from the get-go (which isn’t that hard to do), then it’s pretty straightforward to manage.

[–] Maltese_Liquor 9 points 2 months ago (5 children)

This did little to convince me that timezones are an unnecessary construct. Pretty much every point made was done from the perspective of someone who had already decided their opinion rather than objectively weighing the pros and cons.

load more comments (5 replies)
load more comments (2 replies)
[–] [email protected] 27 points 2 months ago* (last edited 2 months ago) (1 children)

Before timezones and trains, each town had its own natural time (based on the sun or whatever). Would you have preferred that?

load more comments (1 replies)
[–] [email protected] 25 points 2 months ago (1 children)

I feel you're conflating TimeZones with ever-changing Daylight Savings time rules.

[–] [email protected] 10 points 2 months ago (1 children)

True but so do most computers. Computers have a database of timezones and time offsets around the world. Depending on the UTC date and time, and your current timezone it will look up what offset to apply to show the local time. The database is very gnarly since rules change over time, e.g. maybe in the 70s some countries had longer DST to counteract oil shortages.

[–] [email protected] 10 points 2 months ago (1 children)
load more comments (1 replies)
[–] [email protected] 20 points 2 months ago* (last edited 2 months ago) (12 children)

I've just said 'fuck it' and switched all my clocks to UTC. I don't even care anymore.

load more comments (12 replies)
[–] [email protected] 20 points 2 months ago* (last edited 2 months ago) (31 children)

Cool, so sunrise is at 8 PM now. Or maybe there's just no consistent relationship between what a clock on the East and West coast of America say, and a call can't be scheduled between them.

The real problem with time and date is that it has to fit social and natural systems as well as actual passage of time. A lot of nuance is unavoidable.

[–] [email protected] 22 points 2 months ago (1 children)

Yeah, tbh the "no timezones" approach comes with its own basket of problems that isn't necessarily better than the "with timezones" basket. The system needed to find a balance between being useful locally, but intelligible across regions. Especially challenging before ubiquitous telecommunications

Imagine having to rethink the social norms around time every time you travel or meet someone from far away. They say "Oh I work a 9-to-5 office job" and then you need to figure out where they live to understand what that means. Or a doctor writes a book where they recommend that you get to bed by 2:00PM every night, and then you need to figure out how to translate that to a time that makes sense for you.

We'd invent and use informal timezones anyway, and then we'd be writing Javascript functions to translate "real" times to "colloquial" times, and that's pretty close to just storing datetimes in UTC then translating them to a relevant timezone ad hoc, which is what we're already doing.

That's what my rational programmer brain says. My emotional programmer brain is exactly this meme.

load more comments (1 replies)
load more comments (30 replies)
[–] [email protected] 17 points 2 months ago (2 children)

But if time travel is a thing, imagine the whole new time nightmares! Oh you went back a year with your phone? Now all your TLS root certs are invalid because you're before the start date. Or you have files/emails/whatever that are dated in the future. I guess you can get to that state by just setting your clock forward but I imagine some stuff would break.

load more comments (2 replies)
[–] [email protected] 15 points 2 months ago* (last edited 2 months ago) (13 children)

I once developed an electronic program guide for a cable TV company in New Zealand and I'd lose my mind if I had to use timezones. The basic rule of thumb was:

a) Internally you use UTC religiously. UTC is the same everywhere on Earth, time always goes forward, most languages have classes that represent instants, durations etc. In addition you make damned sure your server time is correct and UTC.

b) You only deal with timezones when presenting something to a user or taking input from a user

Prior to that I had worked for a US trading company that set all their servers to EST and was receiving trades through the system which expressed time & date ambiguously. Just had to assume everywhere that EST was the default but it was just dumb programming and I bet to this day every piece of code they develop has time bugs.

load more comments (13 replies)
[–] [email protected] 13 points 2 months ago* (last edited 2 months ago) (4 children)

Except if there was only one zone of time that would be hell to program too because then you would need to check for different times of day for different locations. I think programming is just difficult lol

load more comments (4 replies)
[–] [email protected] 8 points 2 months ago (2 children)

The only code with timezones should be the bit squishy meat bags touch. Everything's is should be UNIX time. Or it you are unfortunate enough to be on Windows, NT time.

Some unfortunate programmers already have to deal with the speed of time not being a constant. In a distant future, timestamps might always have a universal position (and speed), and is that much different from timezones?

Or we find some way of removing time distortion of physics. Find the universe's real systick. 😃

load more comments (2 replies)
load more comments
view more: next ›