I'd like to take a different tack on this issue (though I do agree with the other posters that you should seek some professional help to ensure you do not have a more severe medical or psychological issue at play).
In this situation you are internalizing the problem entirely on yourself - these are your bad days, you are getting no work done. But it sounds to me that you have a very serious problem with how your work defines productivity and sets deadlines.
If you work in IT then you likely are familiar with terms like
LOE (Level of Effort),
Agile Storypoint and
Team Velocity. These terms exist entirely as a recognition that in order to complete any project goal, very specific measurements around task complexity, team capability and resource allocation need to be calculated. Recognition that distractions and roadblocks will be encountered during these project phases is absolutely important towards properly calculating these measurements (and ultimately the success of the project).
Everybody has bad days... even the healthiest of us. Energetic people will suffer through rough nights of sleep, happy people will go through spurts of sadness, diligent individuals will have trouble focusing.. I guarantee that even the nicest and most professional person you know has chewed someone out before for no reason other than that they "woke up on the wrong side of the bed" (See! It is so common that there exist idioms in English to describe this behavior!)
There is not a single person on this earth (Elon Musk included) that can produce at 100% every single day of the week. If you are using this expectation as your guiding point for normality then you really are setting yourself up for failure. Worse still, if your development team is using some daily measurement of productivity rather than building unforeseen events into their timelines then that needs to be addressed. Software development teams should not measure productivity in daily increments..
I would highly recommend using this project as a learning lesson to in the future:
- Make sure to pad any LOEs with extra time to deal with unforeseen issues (like "off-days")
- Make sure that you are not allocating 100% of your work time towards picking up tasks (you need to build in time for admin work as well)
- Try and focus on deadlines over the course of a Sprint (or a weekly/biweekly period) rather than as a daily goal of productivity
In the meantime... talk to your project manager. Don't tell them about your personal issue (yet) but do tell them that your deadlines are so tight that any minor hiccup will prevent you from hitting your goal. This is a risk of which the manager needs to be aware (and frankly should be a kick in the pants for them to reassess how they are setting these deadlines in the first place).
Lastly... I'm no doctor (so please do go see one) but it should be mentioned that occupational burnout exhibits a lot of the same symptoms as clinical depression. It is extremely common in our profession and if you have been operating at an extreme level of productivity for years that could very much explain some of what you are experiencing.