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.
I prefer fizz-buzz as a question because it is obvious there isn't a library. It is also a problem you should be able to do in an interview. It has enough weirdness that there is no best answer, despite having several workable paths you could try.
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.