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.
Heh ... yeah well I wish I had it to do that.
However, you are asking gotcha questions.