reverendsteveii ,

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.

chayleaf ,

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.

Limonene ,

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

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

BeautifulMind ,
@BeautifulMind@lemmy.world avatar

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?

elvith ,
hakunawazo ,

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

ericbomb ,

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.

Cosmonaut_Collin ,
@Cosmonaut_Collin@lemmy.world avatar

This is why we should just move to a universal time zone and stop with the day light savings.

nxdefiant ,

We have that, it's called Unix time, and the only thing it doesn't account for is time dilation due to relativity.

it's perfect

phoneymouse ,

If your system hasn’t been upgraded to 64-bit types by 2038, you’d deserve your overflow bug

Appoxo ,

Let's just nake it 128-Bit so it's not our problem anymore.
Hell, let's make it 256-Bit because it sounds like AES256

phoneymouse ,

64 bits is already enough not to overflow for 292 billion years. That’s 21 times longer than the estimated age of the universe.

marcos ,

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.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • xkcd@lemmy.world
  • test
  • worldmews
  • mews
  • All magazines