Lengthy-lived initiatives can have… attention-grabbing little corners. Decisions made 13 years in the past can stick round, both as a result of they work effectively sufficient, or as a result of, effectively, each change breaks anyone’s workflow.
So, first off, this operate does two totally various things, relying on what you cross in for
adj. Because the remark tells us, if
adj is fake, we discover the primary day of the month. If
adj is true, we discover the primary day of the week relative to
startOfWeek. Sadly, I am unsure that remark is totally right, as a result of whether or not or not
adj is fake, we do some arithmetic primarily based on
_getAdjustedDay. So, for those who do that for a date in November 2020, with weeks beginning on Sunday, you get the outcomes you expect- as a result of November 1st was a Sunday. However for those who attempt it for October, the “first day” is September 27th, not October 1st.
Possibly that is by intent and design. Possibly it is not. It is exhausting to inform from the remark. However the actual bonus WTF is how they name
this._getAdjustedDay here- passing in two parameters. To a operate which solely expects one. However that operate does use the worth handed in anyway, since it is a property of the category.
Even code that we are able to safely assume is dangerous simply from figuring out its origins can nonetheless discover new methods to shock us. And errors that had been most likely only a fast hack somebody deliberate to repair again in 2007 linger to this present day.