https://xkcd.com/2867

Alt text:

It’s not just time zones and leap seconds. SI seconds on Earth are slower because of relativity, so there are time standards for space stuff (TCB, TGC) that use faster SI seconds than UTC/Unix time. T2 - T1 = [God doesn’t know and the Devil isn’t telling.]

1 point
Deleted by creator
permalink
report
reply
35 points
*

I just spent two days debugging a reporting endpoint that takes in two MM-YYYY parameters and tries to pull info between the first day of the month for param1 and the last day of the month for param2 and ended up having to set my date boundaries as

LocalDate startDate = new LocalDate(1, param1.getMonth(), param2.getYear()); //pretty straightforward, right?

//bump month by one, account for rollover, set endDate to the first of that month, then subtract one day

int endMonth = param2.month == 12 ? param2.month + 1 : 1;

LocalDate endDate = new LocalDate(1, endMonth, param2.year).minusDays(1);

This is extraordinarily simply for humans to understand intuitively, but to code it requires accounting for a bunch of backward edge/corner case garbage. The answer, of course, is to train humans to think in Unix epoch time.

permalink
report
reply
2 points

Unix epoch time is wrong too, as it doesn’t include leap seconds, meaning your time difference will be off by up to 15 seconds.

permalink
report
parent
reply
8 points

In the example you gave, wouldn’t the year be off by one when param2.month is 12?

permalink
report
parent
reply
9 points

I was transcribing it from memory and that exact problem cost me like two hours when I was writing it the first time. Well spotted, now write me a unit test for that case.

permalink
report
parent
reply
2 points

Y’know, I legitimately said to myself “I bet they were writing that from memory and just forgot the edge case. I wonder if that was a problem when doing it originally?” before I wrote that comment. 😂 Time to get some Spock tests set up!

permalink
report
parent
reply
13 points

Using YearMonth.atEndOfMonth would have been the easier choice there, I think

permalink
report
parent
reply
15 points

holy shit, yeah it would have. tyvm, I’ll be putting in a PR first thing monday!

permalink
report
parent
reply
5 points

Would you mind trying to explain (ELI5 style) what you did before and why you are excited for this new method for those of us who dont understand code?

permalink
report
parent
reply
4 points

Unix epoch time in UTC, making sure that your local offset and drift are current at the time of conversion to UTC…

permalink
report
parent
reply
2 points

i don’t even care if its wrong, I just want the code to be readable.

permalink
report
parent
reply
2 points

You should care if it’s wrong.

permalink
report
parent
reply
2 points

All dates and times shall be stored and manipulated in Unix time. Only convert to a readable format at the top of the UI, and forget trying to parse user inputs :P that’s just impossible

permalink
report
parent
reply
3 points

I picture this being read by the fred armisen “believe it or not, straight to jail” character

permalink
report
parent
reply
12 points

C++ user with operator overloading: “T2 minus T1.”

Let someone else implement the class. There’s probably a library for it.

permalink
report
reply
2 points

Is there a straightforward way to know which overloading will be used or is it just a roulette every time you add a sketchy new library to your build?

permalink
report
parent
reply
1 point

That’s fine if T1 and T2 include a datetime with the exact local timezone. A simple timestamp or timestamp + utc offset won’t work.

permalink
report
parent
reply
29 points
*

LOL whenever I have to work with DateTime systems that try to account for every possibility (and fail trying) I am reminded that in some disciplines, it’s acceptable to simplify drastically in order to do ‘close enough’ work.

I mean, if spherical cows are a thing because that makes the math of theoretical physics doable, why not relativity-free or just frame-constant date-time measures that are willing to ignore exotic edge cases like non-spherical livestock?

permalink
report
reply
3 points

Because “relativity” isn’t even close to your biggest problem with time. The way we communicate time changes historically, unpredictably, without obvious record. The only way to know what time you’re talking about is to know exactly how you got your information. What location, measured at what time relative to recorded changes in the local time zone, with how much drift relative to the last time you synchronized to which ntp server, and so on. These things easily account for hours or days of error, not just nanoseconds.

permalink
report
parent
reply
49 points

Ah I’ve gotten to the point where I have to define what “frame” and epoch each time base is in before I’ll touch the representation of time( Unix,Gregorian, etc) .To be honest I’m probably just scratching the surface of time problem.

Hell probably the reason we haven’t seen time travellers is we suck at tracking time and you probably need to accurately know your time and place to a very good precision to travel to a given point and we can’t say where and when that is with enough accuracy to facilitate where to land. And people don’t want to land in the earth’s surface or 10000 km away from a stable orbit. Maybe some writer can build that out for a time travel book or to discount it for some reason lol

permalink
report
reply
1 point
*

Could you eli5 what frame and epoch are? I don’t get why aren’t unix timestamps an adequate way to store time, they seem pretty easy and intuitive

permalink
report
parent
reply
5 points
*

Then there’s continental drift, which as Indiana Jones reminded us this past summer, Archimedes didn’t know about when he built his time machine.

Pet peeve: brushing aside the time travel fantasy element, there is not a single shred of evidence of any type of connection between Archimedes and the Antikythera Mechanism.

As if the only person clever enough in Ancient Greece was that one famous dude from Syracuse.
Ionians: “Are we a joke to you?”

permalink
report
parent
reply
19 points

I recall a short story like that where someone died because they time traveled, but didn’t account for position.

permalink
report
parent
reply
15 points
1 point
*
SPOILER

I want little Emily to change her future. A sequel is needed!

(Thanks for sharing, was a good watch.)

permalink
report
parent
reply

Really good, thanks

permalink
report
parent
reply
4 points

Holy crap I wasn’t ready for that. Great rec tho

permalink
report
parent
reply

xkcd

!xkcd@lemmy.world

Create post

A community for a webcomic of romance, sarcasm, math, and language.

Community stats

  • 1.9K

    Monthly active users

  • 234

    Posts

  • 5.6K

    Comments

Community moderators