Live data from Hacker News

Never write your own date parsing library

zachleat.com

181–190 of 333 posts

Re: Never write your own date parsing library

#181

When ever i see "never implement your own...", i know i want to implement it myself. People say that about hard things, and I only want to do hard things. Nobody wants people who can do easy things, people want people who can do hard things. The only way to learn how to do hard things, is to do hard things, so do the hardest things. So go ahead, write your own date library, your own Unicode font rendering, compiler,…

… but if you plan to sell it, don’t build your own billing system!

Re: Never write your own date parsing library

#183
Great writeup! Your journey perfectly captures the universal developer dilemma: "Never roll your own X... until you absolutely must."

The bundle size reductions are impressive (230kB client-side savings!), and your RFC 9557 alignment is a smart forward-looking move. Two questions:

Edge cases: How does your parser handle leap seconds or pre-1582 Julian dates? (e.g., astronomical data) Temporal readiness: Will @11ty/parse-date-strings become a temporary polyfill until Temporal API stabilizes, or a long-term solution? Minor observation: Your comparison table shows Luxon supports YYYY-MM-DD HH (space separator) while RFC 9557 doesn’t – this might break existing Eleventy setups using space-delimited dates. Maybe worth an explicit migration note?

Regardless, fantastic work balancing pragmatism and standards. The web needs more focused libraries like this!

Re: Never write your own date parsing library

#184
post #180

Earlier quoted context omitted.

I think that advice makes sense in the context of cryptography, where the consequences for getting it wrong can be quite serious indeed. I don't think it holds true for something as unimportant as a date parsing library.

Correct date handling (including parsing) can be monumentally important. Imagine an app that reminds people when to take their medications, for example

You typically take medication at a set time every day. You don’t need to parse dates for that.

Re: Never write your own date parsing library

#185

Earlier quoted context omitted.

In order to have these mature libraries, someone hat to start building them. They all had to to be incomplete, immature and horribly buggy early in their lifetime, too.

Why would I mature yours and deal with those issues when I can just use the already-mature one?

You assume that you always have a mature option available. That's (a) definitely not a totally generalizable assumption and (b) my point is that mature options only exist because the people that developed them just did it when confronted with the task.

Re: Never write your own date parsing library

#186
post #184
post #180

Earlier quoted context omitted.

Correct date handling (including parsing) can be monumentally important. Imagine an app that reminds people when to take their medications, for example

You typically take medication at a set time every day. You don’t need to parse dates for that.

1) Dates are often stored as strings, so parsing them correctly is a necessary component of storing them. Also, those dates need not be simple app state. They could come from an API provided by your doctor/pharmacy

2) Many people (especially the elderly) take enough medications on different schedules that managing them all would be a significant cognitive load for anyone

It’s just an illustrative example, though. My point is getting dates right (including parsing their string representations) often matters quite a bit. If you disagree, let’s argue about that rather than quibble about the minutiae of the example

Re: Never write your own date parsing library

#188
post #168

Earlier quoted context omitted.

I don't think tables are the hard thing. If you wanted to grow your wood, plane and dry it yourself, etc... then you'd be "hard way" building a table. I assume you use tools?

I mean, a table is as hard as you make it. I work with rough construction lumber, and make nice finished goods, my point was that people still do stuff that isn’t worth their time financially.

> I mean, a table is as hard as you make it.

We aren't talking about the same thing: I stated "I don't think tables are the hard thing."

Note the word "the" in front of "hard thing" -- I'm referencing the article we're discussing, which mentions "the hard thing"

Re: Never write your own date parsing library

#189

When ever i see "never implement your own...", i know i want to implement it myself. People say that about hard things, and I only want to do hard things. Nobody wants people who can do easy things, people want people who can do hard things. The only way to learn how to do hard things, is to do hard things, so do the hardest things. So go ahead, write your own date library, your own Unicode font rendering, compiler,…

Yes. Do it.

The only way you understand X is by making your own X and trying to support it for a few decades, and our industry needs more people who understand X; fewer who just ask chatgpt/stackoverflow/google for "the answer".

Re: Never write your own date parsing library

#190
post #102

Earlier quoted context omitted.

By all means, write it. Just don't use it. These warnings are almost always in the context of code you're going to release, not exercises in learning on your own.

I think that advice makes sense in the context of cryptography, where the consequences for getting it wrong can be quite serious indeed. I don't think it holds true for something as unimportant as a date parsing library.

A lot of cryptography relies on dates, time, etc.
Post reply on HN