Software

Applications

Microsoft rang in the new year with a cutesy tweet in C#. Just one problem: The code sucked

When marketing meets coding


Microsoft has ushered in 2022 with an amusing (and now deleted) tweet from its Windows Developer account that answers oh so many questions about the quality of code emitted from Redmond nowadays.

As is so often the case, the code (which looked like it aimed to greet 2022 with a perky "Happy New Year") doesn't appear to have troubled a reviewer before going live. Taking aside the fact that it's going to whinge about it still being 2021 when it isn't, there's also the use of the ToString() method when other properties might well have done the job better. And why the "=="?

Click to enlarge

Still, it's the thought that counts. One should consider oneself fortunate that one's own well-intentioned coding cockups have never plopped out of the social media orifice of a company with a market cap in the trillions.

Memories of having to deal with the frankly barking mad US date format still haunt your correspondent to this very day. And then there were the time zones to worry about...

The tweet attracted the usual barrage of supportive and helpful comments typical of Twitter, including a meme from one of Microsoft's own coding boffins, Scott Hanselman, who later followed up with a useful video he described as "an overly detailed analysis of a bad DateTime comparison in C#."

The video is well worth a watch, not least because it delves into not just the obvious flaws in the code but also other considerations that need to be taken into account when handling dates.

As for the original code... well, at best it'll probably keep insisting it is 2021 aside for one brief second. And let's face it, even that isn't right. As another commenter observed: "Yeah 2021 is wrong. We're still stuck in 2020." ®

Send us news
86 Comments

Windows 95 setup was three programs in a trench coat, Microsoft vet reveals

MS-DOS, a minimal Windows 3.1, and finally the teal delight of Windows 95 awaited installers

£1B lawsuit targets Microsoft for allegedly overcharging Windows customers on other clouds

Yes, we've been over this before - several times, in fact

Windows 11 market share falls despite Microsoft ad blitz

Only 10 months left until Windows 10 end of support and people still seem to prefer it

Microsoft goes thin client with $349 Windows 365 Link mini PC

Just as good as Apple at making squat boxes, but this one doesn't do very much

Microsoft slaps Windows 11 update hold on hardware connected to eSCL devices

Scanners, printers, and... fax machines?

Security? We've heard of it: How Microsoft plans to better defend Windows

Did we say CrowdStrike? We meant, er, The July Incident...

Microsoft reboots Windows Recall, but users wish they could forget

AI snapshot tool stumbles back into the spotlight with more issues

Clues to Windows Intelligence found in Windows 11 builds

Somewhere to find AI settings, or just a button to uninstall the operating system once and for all?

Qualcomm's Windows on Arm push would be great – if only it ran all your software

Until compatibility issues are properly addressed, it'll never stand up to x86

Microsoft finally releases a direct-download Windows 11 on Arm ISO

Good news for supporting Windows on Arm devices and adding new ones

Win a slice of XP cheese if you tell us where Microsoft should put Copilot next

What's that coming over the hill, is it an AI?

Microsoft preps big guns to shift Copilot software and PCs

IT admins be warned: 13,000 tech suppliers coming for your employer's checkbook