982
xkcd #2867: DateTime (imgs.xkcd.com)

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.]

top 50 comments
sorted by: hot top controversial new old
[-] ericbomb@lemmy.world 105 points 9 months ago* (last edited 9 months ago)

We use datediff in sql and let God handle the rest.

"Oh but they're in different time zones" "Oh did you account for if one is in day light savings and other isn't" "Aren't some of these dates stored in UTC and some local?"

Are all problems I do not care about.

load more comments (5 replies)
[-] marcos@lemmy.world 61 points 9 months ago

From the wikipedia:

TCB ticks faster than clocks on the surface of the Earth by 1.550505 × 10−8 (about 490 milliseconds per year)

It's amazing that this level of detail is relevant to anything.

[-] elvith@feddit.de 54 points 9 months ago
[-] hakunawazo@lemmy.world 13 points 9 months ago

Thank you, but I gave up halfway through the list.

[-] kurwa@lemmy.world 8 points 9 months ago

I got to "The day before Saturday is always Friday" and I was like waaaa?

[-] sukhmel@programming.dev 8 points 9 months ago

I thought it is about when Julian calendar was dropped in favour of Gregorian, but that's not it:

Thursday 4 October 1582 was followed by Friday 15 October 1582

[-] elvith@feddit.de 9 points 9 months ago* (last edited 9 months ago)

Also some of the islands around the International Date Line did switch their stance on which side of the Date Line they are. So... they might have had a day twice or lost a whole day in the process. And maybe, they didn't change sides only once...

E.g. see here https://youtu.be/cpKuBlvef6A

[-] sukhmel@programming.dev 3 points 9 months ago

A great video you linked, the missing Friday is in it on timestamp 22:45

The Thursday 29th of December 2011 was followed by Saturday 31st of December 2011 on Samoa

[-] whoisearth@lemmy.ca 4 points 9 months ago

Epoch is your friend, or use UTC. At least that's my layman reasoning. I have no challenges working with DateTime except when I don't know the underlying conditions applied from the source code.

[-] randy@lemmy.ca 10 points 9 months ago

I really wish that list would include some explanations about why each line is a falsehood, and what's actually true. Particularly the line:

The software will never run on a space ship that is orbiting a black hole.

If the author has proof that some software will run on a space ship that is orbiting a black hole, I'd be really interested in seeing it.

[-] nybble41@programming.dev 12 points 9 months ago

Technically isn't the Earth itself a sort of space ship which is orbiting (...a star which is orbiting...) the black hole at the center of the Milky Way galaxy? Not really close enough for time dilation to be a factor, but still.

[-] elvith@feddit.de 7 points 9 months ago

All links to the original article are dead and even archive.org doesn't have a capture either. I guess the argument is along the lines of "it might not be relevant, when you're scripting away some tasks for your small personal projects, but when you're working on a widely used library or tool - one day, it might end up on a space vessel to explore whatever."

E.g. my personal backup script? Unlikely. The Linux kernel? Somewhat plausible.

load more comments (2 replies)
[-] sukhmel@programming.dev 10 points 9 months ago

This one is good (or evil, depends on how you see it):

Human-readable dates can be specified in universally understood formats such as 05/07/11.

[-] elvith@feddit.de 9 points 9 months ago

That one's really good.

Which one is it?

  • July 5th 2011
  • May 7th 2011
  • July 11th 2005
  • November 7th 2005

And is it 2011/2005 or rather 1911/1905, 1811/1805,...?

[-] Kethal@lemmy.world 8 points 9 months ago

Does anyone know what is untrue about "Unix time is the number of seconds since Jan 1st 1970."?

[-] icydefiance@lemm.ee 27 points 9 months ago* (last edited 9 months ago)

When a leap second happens, unix time decreases by one second. See the section about leap seconds here: https://en.m.wikipedia.org/wiki/Unix_time

As a side effect, this means some unix timestamps are ambiguous, because the timestamps at the beginning and the end of a leap second are the same.

[-] nybble41@programming.dev 4 points 9 months ago

It might be more accurate to say that Unix time is the number of days since Jan 1st, 1970, scaled by 24×60×60. Though it gets a bit odd around the actual leap second since they aren't spread over the whole day. (In some ways that would be a more reasonable way to handle it; rather than repeating a second at midnight, just make all the seconds slightly longer that day.)

load more comments (1 replies)
[-] chuck@lemmy.ca 49 points 9 months ago

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

[-] kurwa@lemmy.world 19 points 9 months ago

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

[-] 2deck@lemmy.world 15 points 9 months ago
[-] cheet@infosec.pub 4 points 9 months ago

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

[-] peyotecosmico@programming.dev 4 points 9 months ago

Really good, thanks

load more comments (4 replies)
[-] niktemadur@lemmy.world 5 points 9 months ago* (last edited 9 months ago)

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?"

load more comments (1 replies)
[-] reverendsteveii@lemm.ee 35 points 9 months ago* (last edited 9 months ago)

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.

[-] hikaru755@feddit.de 13 points 9 months ago

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

[-] reverendsteveii@lemm.ee 15 points 9 months ago

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

[-] Jarix@lemmy.world 5 points 9 months ago

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?

[-] reverendsteveii@lemm.ee 8 points 9 months ago

it does in a way that's been reviewed, vetted and tested by a lot of people the thing that I'm trying to do with code that's only ever been seen by me and one other guy and has been tested to this best of my ability, which i hope is quite good but one person can easily miss edge cases and weird coincidences.

load more comments (6 replies)
[-] drislands@lemmy.world 5 points 9 months ago* (last edited 9 months ago)

To break it down a bit further, the code that was provided is specifically trying to get the last day of a month, which I'll call Month X since it will vary. The code is doing these things, in this order:

  1. Get the month after Month X
  2. If Month X is 12 (aka December) get Month 1 instead (aka January)
  3. Get the Date that is day 1 of the Month from step 2
  4. Get the Date that is one day before the Date from step 3

All this to get the last day of the month from Month X. The reason they did it this way is so they didn't have to say "Is this February? Then get day 28. Is this January/March/etc? then get day 31." and so on.

The code that the other user provided will instead get the last day of Month X without having to do all those steps. It's doing something in the background to get the same data, but the coder doesn't have to worry about exactly how because they can trust it will work as expected.

It ultimately boils down to the user carving out a round piece of wood, fitting it on an axle and bolting it on, then to find someone already has cheap wheels for sale that are more stable than what they just made.

load more comments (2 replies)
[-] drislands@lemmy.world 8 points 9 months ago

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

[-] reverendsteveii@lemm.ee 9 points 9 months ago

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.

load more comments (1 replies)
[-] kogasa@programming.dev 4 points 9 months ago

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

load more comments (6 replies)
load more comments (3 replies)
[-] BeautifulMind@lemmy.world 29 points 9 months ago* (last edited 9 months ago)

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?

[-] kogasa@programming.dev 3 points 9 months ago

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.

[-] MxM111@kbin.social 23 points 9 months ago* (last edited 9 months ago)

Not even going to general relativity, as this comics suggests to experience time slowing down due to gravity, the events are not just at time, but also at particular location in space relative particular inertial system. Not specifying it, and not specifying the inertial system for which the final answer is needed makes it impossible to calculate even in special relativity, without effects of gravity.

[-] JohnDClay@sh.itjust.works 20 points 9 months ago

Relevant Tom Scott video the answer depends on location, times, country, religion, and a bunch of other factors.

[-] threelonmusketeers@sh.itjust.works 4 points 9 months ago* (last edited 9 months ago)

I wonder what fraction of xkcd readers have already seen this video... I imagine it is quite high. I know I've watched it multiple times. It's a good one.

load more comments (1 replies)
[-] slice@feddit.de 3 points 9 months ago

Scrolled trough here just to search for this comment 😂

[-] randomaccount43543@lemmy.world 15 points 9 months ago
[-] Limonene@lemmy.world 12 points 9 months ago

C++ user with operator overloading: "T2 minus T1."

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

load more comments (2 replies)
[-] dm_me_your_boobs@lemm.ee 4 points 9 months ago

That's me in the bottom right corner over there.

load more comments (2 replies)
load more comments
view more: next ›
this post was submitted on 14 Dec 2023
982 points (99.2% liked)

xkcd

8582 readers
213 users here now

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

founded 1 year ago
MODERATORS