I suspect that some code uses another date format. If you convert the date to a format where the day number(ordinal dates) of the year is used
Jan 31 = 31
Feb 1= 32
Dec 31 = 365/366 (depending of leap year)
If you calculate it like:
Take the (number for the first day of the month)-1 and add the day of the month.
And then add one if a leap year and month >2
The code is easy to do and will work if input data i correct but it not i would result in this bug. Lots of code assume correct values.
The problem is that it is that the input data is not validate. There has to be som code that changes the impossible date.
A format like that is quite resonable to use because the you can check if a date is before som value with a quick comparison of a integer instead of comparing a long strings. Tests in that format will be faster
Time format like that is often used in for example
https://en.wikipedia.org/wiki/Unix_time