See Essex's best wedding venues at this year's Wedding Awards
Claiming the economy is strong while, at the same time, blaming everyone else for the fact that it manifestly isn't. No one believes a word she says any more. Rachel Reeves is deluded, says DAN HANNAN
Britney Spears unleashes on ex Kevin Federline AND her SONS - accusing him of 'gaslighting' and claiming she's seen one boy for just 45 minutes in five years
Chinese stole state secrets from No.10 for YEARS: Catastrophic blunder heaps fresh pressure on Starmer over collapsed spying case - as government releases key documents
End of support for older Office and Windows Server versions pile on the pain for admins
Windows 10's free support has shuffled off this mortal coil for most customers – but that's merely the headline act in Microsoft's October support massacre. Older versions of Office and Windows Server have also been shown the door.…
How to tell when headaches, tiredness and forgetfulness are hidden signs of a brain tumour, according to experts
10 baby names at risk of becoming extinct in 2026
Moment Tim Hortons boss chases Algerian illegal migrant who snatched £65,000 Patek Philippe watch from his wrist as he walked through Mayfair
New Alzheimer's Treatment Clears Plaques From Brains of Mice Within Hours
Read more of this story at Slashdot.
Diane Keaton's cause of death revealed just days after actress' passing at 79 as her family pens emotional message to fans
More unseen moments of awkward Keir Starmer caught on camera at Gaza peace talks
Here comes the Sumo: Wrestlers recreate iconic image of the Beatles on Abbey Road before competing at Royal Albert Hall
Animal charity calls for roadside memorial after chicken lorry catches fire on A12
Pet cat rescued at Halstead High Street fire caused by logs near log burner
Representative Line: A Date Next Month
We all know the perils of bad date handling, and Claus was handed an annoying down bug in some date handling.
The end users of Claus's application do a lot of work in January. It's the busiest time of the year for them. Late last year, one of the veteran users raised a warning: "Things stop working right in January, and it creates a lot of problems."
Unfortunately, that was hardly a bug report. "Things stop working?" What does that even mean. Claus's team made a note of it, but no one thought too much about it, until January. That's when a flood of tickets came in, all relating to setting a date.
Now, this particular date picker didn't default to having dates, but let the users pick values like "Start of last month", or "Same day last year", or "Same day next month". And the trick to the whole thing was that sometimes setting dates worked just fine, sometimes it blew up, and it seemed to vary based on when you were setting the dates and what dates you were setting.
And let's take a look at one example of how this was implemented, which highlights why January was such a problem:
startDate = startDateString == "Start of last month" ? new DateTime(today.Year, today.Month-1, 1) : startDate;They construct a new date out of the current date, by subtracting one from the Month of the current date. Which would never work for January.
And this pattern was used for all of their date handling. So "Same Day Next Month" worked fine- unless the current date was near the end of January, since they just added one to the month. Of course, "Same day next year" blows up on February 29th. And "Same day next/last week" works by adding or subtracting 7 from the day, which does not play nicely with month boundaries.
The fix was obvious: rewrite all of the code to do proper date arithmetic. The nuisance to the whole thing was that there were just a lot of "default" date arrangements that the software supported, so it was a surprising amount of effort to fix. And, given the axiom that "every change breaks somebody's workflow", there were definitely a few users who objected to the fixes- they were using the broken behavior as part of their workflow (and perhaps an excuse for why certain scheduling arrangements were "forbidden").
As a bonus complaint, I will say, I don't love the use of string literals to represent the different kinds of operations. It's certainly not the WTF here, but I am going to complain about it anyway.