this post was submitted on 03 Apr 2024
55 points (98.2% liked)

Programmer Humor

19315 readers
88 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
[–] Malix@sopuli.xyz 13 points 6 months ago (29 children)

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

[–] Scoopta@programming.dev 4 points 6 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.

[–] hikaru755@lemmy.world 4 points 6 months ago* (last edited 6 months ago)

Not really. Timezones, at their core (so without DST or any other special rules), are just a constant offset that you can very easily translate back and forth between, that's trivial as long as you remember to do it. Having lots of them doesn't really make anything harder, as long as you can look them up somewhere. DST, leap seconds, etc., make shit complicated, because they bend, break, or overlap a single timeline to the point where suddenly you have points in time that happen twice, or that never happen, or where time runs faster or slower for a bit. That is incredibly hard to deal with consistently, much more so that just switching a simple offset you're operating within.

[–] fidodo@lemmy.world 3 points 6 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 (5 replies)
[–] usualsuspect191@lemmy.ca 2 points 6 months ago (7 children)

I love DST! I just think ever switching out of it is where the mistake lies

load more comments (7 replies)
[–] CosmicCleric@lemmy.world 2 points 6 months ago

Love me some early evening daylight though. Nice warm but not hot cruise/drive with the windows and the top down on the car.

[–] scottywh@lemmy.world 1 points 6 months ago (3 children)

Switching sucks but DST is better than Standard Time.

[–] snooggums@midwest.social 2 points 6 months ago* (last edited 6 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@lemmy.world 3 points 6 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 (25 replies)
[–] fubarx@lemmy.ml 6 points 6 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.

[–] LodeMike@lemmy.today 2 points 6 months ago (3 children)

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

[–] fubarx@lemmy.ml 4 points 6 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.

[–] AMDIsOurLord@lemmy.ml 3 points 6 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)

[–] fubarx@lemmy.ml 3 points 6 months ago (1 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.

[–] AMDIsOurLord@lemmy.ml 2 points 6 months ago (1 children)

God I'm sorry you had to go through that much middle management bullshit

[–] fubarx@lemmy.ml 1 points 6 months ago

Thanks. On the plus side, I got to try 'soup dumpling' -- still the best I've ever had. And Kaoliang, the most gut-busting distilled beverage known to mankind. OTOH, the product shipped, won lots of awards, and got national coverage for the company.

Nothing to do with timezones, but still, fun times.

[–] dan@upvote.au 1 points 6 months ago* (last edited 6 months ago) (4 children)

Unix time.

Unix time doesn't help with timezones... It's always in UTC.

Unix timestamps also get a bit weird because of leap seconds. Unix timestamps have no support for leap seconds (the POSIX spec says a Unix day is always exactly 86400 seconds), so they're usually implemented by repeating the same timestamp twice. This means that the timestamp is ambiguous for that repeated second - one timestamp actually refers to two different moments in time. To quote the example from Wikipedia:

Unix time numbers are repeated in the second immediately following a positive leap second. The Unix time number 1483142400 is thus ambiguous: it can refer either to start of the leap second (2016-12-31 23:59:60) or the end of it, one second later (2017-01-01 00:00:00). In the theoretical case when a negative leap second occurs, no ambiguity is caused, but instead there is a range of Unix time numbers that do not refer to any point in UTC time at all.

Some systems instead spread a positive leap second across the entire day (making each second a very very tiny bit longer) but technically this violates POSIX since it's modifying the length of a second.

Aren't timestamps fun?

Luckily, the standards body that deals with leap seconds has said they'll be discontinued by 2035, so at least it's one less thing that developers dealing with timestamps will have to worry about.

Don't try to write your own date/time code. Just don't. Use something built by someone else.

load more comments (4 replies)
load more comments (1 replies)
load more comments (2 replies)
[–] perviouslyiner@lemmy.world 5 points 6 months ago (1 children)
[–] steeznson@lemmy.world 3 points 6 months ago (6 children)

The UK press every year makes a huge song and dance in opinion pieces about getting rid of DST. However I'm always horrified to see that people want us to keep British Summer Time instead of Grenwich Mean Time. I understand that there are "longer evenings" in BST; however we literally invented GMT and coerced the rest of the world to adjust their times based on that. From the point of view of being constantly compatible with UTC and having more consistent business hours for international companies it makes more sense to me if we kept GMT.

Also the longer evenings thing can be achieved by simply staying up an hour later. It's not exactly like an hour is being stolen from you when the times switch, the change of clocks are mainly pointless admin.

Lastly I read an article recently that described a correlation between the incidence of heart attacks and the clocks changing. The theory is that just slightly messing with people's sleeping patterns can cause additional strain on the body.

[–] AngryCommieKender@lemmy.world 2 points 6 months ago

Another point for GMT, in the mid '70s, the US went onto DST year round for a couple years. People hated it so much they changed back to switching the time.

If we wanna do away with DST and BST, we need to go back to standard time, as the later sunset in the summer translates to no sunlight for workers in the winter

load more comments (5 replies)
[–] ytg@sopuli.xyz 1 points 6 months ago* (last edited 6 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?

[–] vox@sopuli.xyz 2 points 6 months ago

tbf there are libraries capable of handling that too, like rust's chrono

[–] lhamil64@programming.dev 1 points 6 months ago

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.

[–] ipkpjersi@lemmy.ml 1 points 6 months ago* (last edited 6 months ago)

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

[–] corsicanguppy@lemmy.ca 1 points 6 months ago (1 children)

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

[–] arc@lemm.ee 1 points 6 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.

[–] brianorca@lemmy.world 1 points 6 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.

load more comments
view more: next ›