Feed aggregator
Iran Bans Officials From Using Internet-Connected Devices
Read more of this story at Slashdot.
Salesforce Announces 6% Price Increase as It Pushes AI Features
Read more of this story at Slashdot.
Meetings After 8 p.m. Are On the Rise, Microsoft Study Finds
Read more of this story at Slashdot.
'Firefox Is Dead To Me'
Read more of this story at Slashdot.
AI Use at Work Nearly Doubles in Two Years
Read more of this story at Slashdot.
How Do Olympiad Medalists Judge LLMs in Competitive Programming?
Read more of this story at Slashdot.
'Titan' Netflix Documentary Examines Events Leading To OceanGate's Doomed Expedition
Read more of this story at Slashdot.
Microbe With Bizarrely Tiny Genome May Be Evolving Into a Virus
Read more of this story at Slashdot.
Denmark Tests Unmanned Robotic Sailboat Fleet
Read more of this story at Slashdot.
CodeSOD: A Second Date
Ah, bad date handling. We've all seen it. We all know it. So when Lorenzo sent us this C# function, we almost ignored it:
private string GetTimeStamp(DateTime param) { string retDate = param.Year.ToString() + "-"; if (param.Month < 10) retDate = retDate + "0" + param.Month.ToString() + "-"; else retDate = retDate + param.Month.ToString() + "-"; if (param.Day < 10) retDate = retDate + "0" + param.Day.ToString() + " "; else retDate = retDate + param.Day.ToString() + " "; if (param.Hour < 10) retDate = retDate + "0" + param.Hour.ToString() + ":"; else retDate = retDate + param.Hour.ToString() + ":"; if (param.Minute < 10) retDate = retDate + "0" + param.Minute.ToString() + ":"; else retDate = retDate + param.Minute.ToString() + ":"; if (param.Second < 10) retDate = retDate + "0" + param.Second.ToString() + "."; else retDate = retDate + param.Second.ToString() + "."; if (param.Millisecond < 10) retDate = retDate + "0" + param.Millisecond.ToString(); else retDate = retDate + param.Millisecond.ToString(); return retDate; }Most of this function isn't terribly exciting. We've seen this kind of bad code before, but even when we see a repeat like this, there are still special treats in it. Look at the section for handling milliseconds: if the number is less than 10, they pad it with a leading zero. Just the one, though. One leading zero should be enough for everybody.
But that's not the thing that makes this code special. You see, there's another function worth looking at:
private string FileTimeStamp(DateTime param) { string retDate = param.Year.ToString() + "-"; if (param.Month < 10) retDate = retDate + "0" + param.Month.ToString() + "-"; else retDate = retDate + param.Month.ToString() + "-"; if (param.Day < 10) retDate = retDate + "0" + param.Day.ToString() + " "; else retDate = retDate + param.Day.ToString() + " "; if (param.Hour < 10) retDate = retDate + "0" + param.Hour.ToString() + ":"; else retDate = retDate + param.Hour.ToString() + ":"; if (param.Minute < 10) retDate = retDate + "0" + param.Minute.ToString() + ":"; else retDate = retDate + param.Minute.ToString() + ":"; if (param.Second < 10) retDate = retDate + "0" + param.Second.ToString() + "."; else retDate = retDate + param.Second.ToString() + "."; if (param.Millisecond < 10) retDate = retDate + "0" + param.Millisecond.ToString(); else retDate = retDate + param.Millisecond.ToString(); return retDate; }Not only did they fail to learn the built-in functions for formatting dates, they forgot about the functions they wrote for formatting dates, and just wrote (or realistically, copy/pasted?) the same function twice.
At least both versions have the same bug with milliseconds. I don't know if I could handle it if they were inconsistent about that.
[Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.Social Media Now Main Source of News In US, Research Suggests
Read more of this story at Slashdot.
Your Brain Has a Hidden Beat -- and Smarter Minds Sync To It
Read more of this story at Slashdot.
Google Cloud Caused Outage By Ignoring Its Usual Code Quality Protections
Read more of this story at Slashdot.
Intel Will Lay Off 15% To 20% of Its Factory Workers, Memo Says
Read more of this story at Slashdot.
Vandals Cut Fiber-Optic Lines, Causing Outage For Spectrum Internet Subscribers
Read more of this story at Slashdot.
Threads Will Let You Hide Spoilers In Your Posts
Read more of this story at Slashdot.
Salesforce Study Finds LLM Agents Flunk CRM and Confidentiality Tests
Read more of this story at Slashdot.
The US Navy Is More Aggressively Telling Startups, 'We Want You'
Read more of this story at Slashdot.
Obscure Chinese Stock Scams Dupe American Investors by the Thousands
Read more of this story at Slashdot.
OpenAI, Growing Frustrated With Microsoft, Has Discussed Making Antitrust Complaints To Regulators
Read more of this story at Slashdot.