Feed aggregator
Universe Expected To Decay Much Sooner Than Previously Thought
Read more of this story at Slashdot.
CodeSOD: Exactly a Date
Alexandar sends us some C# date handling code. The best thing one can say is that they didn't reinvent any wheels, but that might be worse, because they used the existing wheels to drive right off a cliff.
try { var date = DateTime.ParseExact(member.PubDate.ToString(), "M/d/yyyy h:mm:ss tt", null); objCustomResult.PublishedDate = date; } catch (Exception datEx) { }member.PubDate is a Nullable<DateTime>. So its ToString will return one of two things. If there is a value there, it'll return the DateTimes value. If it's null, it'll just return an empty string. Attempting to parse the empty string will throw an exception, which we helpfully swallow, do nothing about, and leave objCustomResult.PublishedDate in whatever state it was in- I'm going to guess null, but I have no idea.
Part of this WTF is that they break the advantages of using nullable types- the entire point is to be able to handle null values without having to worry about exceptions getting tossed around. But that's just a small part.
The real WTF is taking a DateTime value, turning it into a string, only to parse it back out. But because this is in .NET, it's more subtle than just the generation of useless strings, because member.PubDate.ToString()'s return value may change depending on your culture info settings.
Which sure, this is almost certainly server-side code running on a single server with a well known locale configured. So this probably won't ever blow up on them, but it's 100% the kind of thing everyone thinks is fine until the day it's not.
The punchline is that ToString allows you to specify the format you want the date formatted in, which means they could have written this:
var date = DateTime.ParseExact(member.PubDate.ToString("M/d/yyyy h:mm:ss tt"), "M/d/yyyy h:mm:ss tt", null);But if they did that, I suppose that would have possibly tickled their little grey cells and made them realize how stupid this entire block of code was?
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today! -->Creatives Demand AI Comes Clean On What It's Scraping
Read more of this story at Slashdot.
Reddit Turns 20
Read more of this story at Slashdot.
Google Developing Software AI Agent
Read more of this story at Slashdot.
Asking Chatbots For Short Answers Can Increase Hallucinations, Study Finds
Read more of this story at Slashdot.
Google Launches New Initiative To Back Startups Building AI
Read more of this story at Slashdot.
Philips Debuts 3D Printable Components To Repair Products
Read more of this story at Slashdot.
VPN Firm Says It Didn't Know Customers Had Lifetime Subscriptions, Cancels Them
Read more of this story at Slashdot.
Nations Meet At UN For 'Killer Robot' Talks
Read more of this story at Slashdot.
Google Updating Its 'G' Icon For the First Time In 10 Years
Read more of this story at Slashdot.
Ticketmaster Now Shows Full Price of Tickets Up Front
Read more of this story at Slashdot.
New Pope Chose His Name Based On AI's Threats To 'Human Dignity'
Read more of this story at Slashdot.
Apple To Lean on AI Tool To Help iPhone Battery Lifespan for Devices in iOS 19
Read more of this story at Slashdot.
Nvidia Reportedly Raises GPU Prices by 10-15%
Read more of this story at Slashdot.
Chegg To Lay Off 22% of Workforce as AI Tools Shake Up Edtech Industry
Read more of this story at Slashdot.
Climate Crisis Threatens the Banana, the World's Most Popular Fruit
Read more of this story at Slashdot.
Western Digital Invests in Ceramic Storage Firm That Claims 5,000-Year Data Retention
Read more of this story at Slashdot.
Apple Considering Raising iPhone Prices
Read more of this story at Slashdot.
Is There Water on Mars?
Read more of this story at Slashdot.