All my experience in trying to hire developers has been wading through an endless stream of people who were just useless.
Me: I want to represent a 2d grid, what data structure should we use? Them: A string?
This was someone applying for senior engineer. Others I've had filled their CV with SQL related acronyms. But couldn't explain what a foreign key was and then stubbornly insisted that at their current corp they would never ever use foreign keys in their SQL database!
I've had senior engineer when asked how to check if we had a 2d array with an item at x,y tell me if anything is on the same column or row, they couldn't do it, couldn't even verbalise how to approach it.
"Web Developers" who didn't know the difference between GET and POST. Web Developers that have never heard of PUT or what it would be used for.
The answer that almost guarantees I'll hire you is "there's got to be a library function for that, so I look in the manual". Almost as good is somebody whiteboarding how they'd convert ddd to mm-dd (and then account for leap years, etc.)
I get a disturbing number of people who say things like "I would communicate with the person asking for this to see what they're really intending blah blah"
My favorite answer was on a phone interview where he just hung up and wouldn't answer when we called back.
Sounds like they know this question is a “gotcha” question but just misinterpreted which direction you were going with it.
Some will ask a question like this expecting you to treat it like a puzzle and outline how you’d solve it as-is; others ask it as a way to probe how you’ll deal with strange or misguided requests (the case you noted as disturbing); and others yet will ask it to see how you’d practically solve it (your intention).
Seems like a bad interview question without context regarding kind of answer you’re looking for.
If you would ask someone to write a piece of code, and a part of the problem is this conversion, then you would be right to expect they reach for a library, but even if they don't you would be giving them the opportunity to explain themselves, and judge the explanation, not the answer. Also, if your test is "does this person reach for a library at the right time", you could do a lot less esoteric and confusing by just asking them to add 10 days to a date. If you just ask this one specific problem, it is likely they assume you are looking for them to demonstrate the skills involved in actually solving the problem, i.e. leetcode.
This is also why some people give you the blabla answer, because it is indeed very unlikely that someone needs to do this legitimately. This is because its a toy problem. Someone's professional reaction to the problem in isolation should indeed be: this is weird, I've never been asked something like this, what's up?
Finally, even though the question is terrible, I would still rate the "whatsup?" response higher than the "leapyear" response. I would want a developer to triple check that this problem needs solving, before they would solve it themselves.
Finally finally, if there's one answer to one question that, when answered trivially in a way literally taught in most basic programming courses (use the standard library / a third party library), makes them a "guaranteed hire", I also have significant doubts about the level of talent you are bringing in, as any experienced interviewer will tell you that qualified people will get important questions wrong, and unqualified people will get important questions right.
I understand that this reaction might be quite harsh, and I know better than anyone that its hard and time consuming to do good interviews, but please consider that you are rejecting people who may be very confused and sad by this way of rejection.
Heh ... yeah well I wish I had it to do that.
However, you are asking gotcha questions.