How I built a date picker
In this technical retrospective (2022), @zsbenke shares practical architectural lessons learned from running, scaling, or migrating production software under lean constraints.
Core Principles for Independent Builders:
Defaulting to simpler architectures (such as monolithic frameworks, SQLite, or managed VPS) prevents early engineering bankruptcy.
Evaluating true compute and egress costs reveals that high cloud bills can often be slashed by 80%+ through judicious re-platforming.
Code you write at 2 AM as a solo engineer must be easy to debug six months later without complex microservice dependencies.
Community Debate Themes:
HN engineers debated the tradeoffs between cloud convenience and raw server economics, database indexing strategies, and resisting premature architectural complexity.
CATEGORY Frugal Engineering →
HISTORICAL ERA Pandemic Bubble (2020–2022)
COMMUNITY SCORE ★ 66 points
TOTAL DISCUSSIONS 56 comments
Coincidentally I built one yesterday at well. Opposite approach. As little code as possible.
First of all
``` Input type=date
``` On Android shows a date picker that many users have found confusing to operate. They can't figure out how to select the year. I used to say "not my problem" but it actually was because they still complained.
So
``` Input type=month
``` Solves that first problem and then a day selector does the rest but that's an unfamiliar paradigm so...
I wanted year/month/day in a way that uses will find easy. One for each then.
There's many existing options and they use a lot of code. I mean just an insane amount. I don't want a boatload of code to select a date in a way that users won't complain.
The browser already knows everything about dates, so we can just ask it how many days are in a month and what the name of the month is.
Leap years, leap seconds, it's all in there. No wheel reinventing necessary
So we have one of our two key lines
``` let maxday = new Date(year, month, 0).getDate(); ``` (It'll be further explained at the end.)
2nd part; let's not have an array of month names. Instead, let's ask the browser for what the user calls the months based on their first language:
``` Intl.DateTimeFormat( navigator.languages[0], {month: 'long'}) .format( new Date(startyear, i) )
``` So they select the year, then the month, then we use that as a query to find out how many days are in the month by asking the default Date object, already built in.
And all together now https://gist.github.com/kristopolous/d956c148ddcb628d54ec5118a139b9dc
Btw, this is for a product related to driving a car so we aren't dealing with blind users. A lot of accessibility things were skipped
What would improve my quality of life is if date pickers used some global cookie mechanism to share recent dates between websites. The number of times I'm looking at flights/hotels around the web and have to keep entering the same date on infuriatingly different date pickers is soul destroying.
At least allow a date to be pasted in and have the logic to accept if the user has entered something thats different from what the backend needs but makes sense for the the current date and their locale: "22 feb" "22/02/2022" "22/2" "2/22" etc
Please please please don't do this! This article doesn't even mention ARIA and the result would fail any accessibility audit.
There is really no way to implement this in JS anyway because all major browsers have native date pickers by now: https://caniuse.com/input-datetime
Why does every website in the world insist on having its own massively over-engineered GUI to solve this problem?
Use a text entry field, validate it with a regex, and have an error message that says "YYYY-MM-DD plz" if it fails the regex.
I mostly gave up on date pickers, I prefer entering a datetime as text and if it can automatically figure out the format I'm using then it's godsend. Clicking tiny buttons with unknown behavior takes way too much time