Live data from Hacker News

Never write your own date parsing library

zachleat.com

311–320 of 333 posts

Re: Never write your own date parsing library

#311
post #306
post #287

Earlier quoted context omitted.

Just FYI you were downvoted with no explanation because you missed the point in all of these and you're using a smug and off-putting tone which makes it look like only care about "being right" and not finding what "is right". Also you obviously didn't bother reading the "important concepts" link ([3]). I was going to assume good faith and reply to each of your comments but it'd probably be a waste of time. As a summa…

> FYI you were downvoted with no explanation because you missed the point in all of these I think people downvote things they disagree with, and I'm not surprised people who think handling dates and times is beyond them are mad at someone exists who doesn't, because I'm calling out their impotence in a way. And I understand you don't want to feel impotent, so telling me that you're not going to respond to me is a way…

> Then prove it: How exactly do you think you can meaningfully add two PlainMonthDays? What does such a thing mean?

Star Wars day is May the 4th. Today is May the 1st. Star Wars day is in 3 days.

I'll stop here.

Re: Never write your own date parsing library

#312

Earlier quoted context omitted.

I agree with the gist of your comment but I think you’re using the wrong words. A time zone, as the name implies, is a zone, a place. The most common way to indicate a timezone is a continent+city combo that is both politically and geographically close, so it’s unlikely to change. Therefore, I very much know the timezone of Frankfurt, both today and in the reasonably close future, namely “Europe/Berlin”. You’re talki…

Well, not really. :) Timezones are the whole area that has the same time. So "Europe/Berlin" and "Europe/Rome" right now can be used in user-facing help texts to make the timezone understandable, but those cities might not be in the help text in the future. That's because: "Each time zone is defined by a standard offset from Coordinated Universal Time (UTC)." ( https://en.m.wikipedia.org/wiki/Time_zone ) So the offse…

The offset changes twice a year in many countries due to the misbegotten Daylight Saving Time. What's worse, governments can and do change the dates of the transition so you need something like the Olson (RIP) database to do retroactive time calculations. The US changed its DST dates in 2007, for instance.

Re: Never write your own date parsing library

#313

Earlier quoted context omitted.

> That's a localized date and time. Note that I'm not arguing against storing the numeric part in a consistent format, of course you should. My point is that right mow in 2025 you don't know the timezone. E.g. if you write that as the zones are now, it would be "2029-07-26T11:00:00.000Z", but if the timezones change, then when a person is looking at their calendar in 2029, they will be an hour early or late to the me…

Ah I have the perfect solution. Let's add GPS coordinates to datetime stamps! Please put the pitchfork away it was only a joke. (Until someone actually does this because it makes a twisted sort of sense)

The good thing about this proposal is that GPS coordinates include altitude, so you could use them to correct for gravitational time dilation due to General Relativity.

Re: Never write your own date parsing library

#314

I ran into date heck recently in a medical setting for storing birthdates. Eventually I settled on the idea that a birthdate isn’t a physical time, it’s just a string. We can force the user to enter it in the format 02/18/1993 leading zeroes and all, and operations on it other than string equality are invalid. We’ll see if this survives contact with the enemy but it’s already going better than storing and reasoning a…

What environment are you in where you have to work with birthdates, you have timezone aware dates, times, and intervals, but you don't have a naive/plain/local date type that already exists forcing you to use strings in place of date-without-timezone? You seem to have a reasonably expedient solution for that problem, but it is surprising to have the combination of things you have to have and things you have to be mis…

Javascript/swift/kotlin frontend, python backend, mysql server. The problem wasn’t that I had access to zero (presumably) well implemented time abstractions with all the bells and whistles, it was that I had five well implemented native time abstractions.

Re: Never write your own date parsing library

#315
post #311
post #306

Earlier quoted context omitted.

> FYI you were downvoted with no explanation because you missed the point in all of these I think people downvote things they disagree with, and I'm not surprised people who think handling dates and times is beyond them are mad at someone exists who doesn't, because I'm calling out their impotence in a way. And I understand you don't want to feel impotent, so telling me that you're not going to respond to me is a way…

> Then prove it: How exactly do you think you can meaningfully add two PlainMonthDays? What does such a thing mean? Star Wars day is May the 4th. Today is May the 1st. Star Wars day is in 3 days. I'll stop here.

You might want to look in a dictionary and see what `add` means.

4May+1May is still not meaningful to me, and frankly I do not believe that it is meaningful to you. I do not think you have thought about what I am saying at all, and think it's shocking that you have an opinion about something you clearly don't understand.

Re: Never write your own date parsing library

#316

Earlier quoted context omitted.

That clock hasn't actually been built yet and it wouldn't be useful for guiding nuclear missiles. https://en.wikipedia.org/wiki/Nuclear_clock

I mean, than nucleus is much heavier and much smaller than electron, so it will be much less affected by external forces. We may see no difference between sea level and space based Thorium-229 clocks, or difference will be much smaller.

ICBMs can be aimed as accurately as they need to be with current inertial navigation technology.

Re: Never write your own date parsing library

#317
> Consider "200". Is this the year 200? Is this the 200th day of the current year? Surprise, in ISO 8601 it’s neither — it’s a decade, spanning from the year 2000 to the year 2010. And "20" is the century from the year 2000 to the year 2100.

In any sane system, giving a function "200" as an input and asking what date/datetime it represents should return some sort of error.

Some inputs are too ambiguous to meaningfully parse.

Re: Never write your own date parsing library

#318
post #315
post #311

Earlier quoted context omitted.

> Then prove it: How exactly do you think you can meaningfully add two PlainMonthDays? What does such a thing mean? Star Wars day is May the 4th. Today is May the 1st. Star Wars day is in 3 days. I'll stop here.

You might want to look in a dictionary and see what `add` means. 4May+1May is still not meaningful to me, and frankly I do not believe that it is meaningful to you. I do not think you have thought about what I am saying at all, and think it's shocking that you have an opinion about something you clearly don't understand.

You might want to look in a dictionary and see what `subtract` means.

4May-1May is meaningful to me, and frankly I do believe that it is meaningful to you. I do not think you have thought about what we are saying at all, and think it's shocking that you have an opinion about something you clearly don't understand.

Re: Never write your own date parsing library

#319
post #315

Earlier quoted context omitted.

You might want to look in a dictionary and see what `add` means. 4May+1May is still not meaningful to me, and frankly I do not believe that it is meaningful to you. I do not think you have thought about what I am saying at all, and think it's shocking that you have an opinion about something you clearly don't understand.

You might want to look in a dictionary and see what `subtract` means. 4May-1May is meaningful to me, and frankly I do believe that it is meaningful to you. I do not think you have thought about what we are saying at all, and think it's shocking that you have an opinion about something you clearly don't understand.

> 4May-1May is meaningful to me

Great, but it isn't addition.

> and frankly I do believe that it is meaningful to you.

Well you're wrong.

Consider 1Mar-28Feb: Should this be 1 or 2?

This proves it can't be subtraction (in the arithmetic sense) either.

> You might want to look in a dictionary and see what `subtract` means.

Subtraction is only addition if 4May-1May is equivalent to 4May+-1May which leaves you with an additional problem: What to do about negative plaindates.

> I do not think you have thought about what we are saying at all

I've probably thought about it too much at this point. You don't even know how arithmetic works, so I think if you have anything to say it will be too difficult for me to understand.

Re: Never write your own date parsing library

#320

Earlier quoted context omitted.

What IS the right way to model dates in a pacemaker ...? I hope the answer is "just don't do it" -- but I don't know what reasons there might be for a pacemaker to need to depend on calendar dates in order to best do its job ...

Well naturally it will need to connect to your phone via Bluetooth for the app to proxy update downloads and historic location data uploads. But in order to do anything on the network securely you need an accurate clock and the ability to parse datetimes because the PKI implementation depends on that. Then the app pings you to remind you that your premium subscription will be expiring soon after which your heart rate…

Hopefully no real pacemaker manufacturer is allowed to do that. Creating radiation in the middle of a body near a critical organ without a medical reason sounds like a really dumb idea.

Also you want the pacemaker to be as air-gapped and simple as possible, because it needs 100% uptime.

(maybe I missed the implied /s)

Post reply on HN