Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      GitHub’s CEO Thomas Dohmke steps down, triggering tighter integration of company within Microsoft

      August 12, 2025

      bitHuman launches SDK for creating AI avatars

      August 12, 2025

      Designing With AI, Not Around It: Practical Advanced Techniques For Product Design Use Cases

      August 11, 2025

      Why Companies Are Investing in AI-Powered React.js Development Services in 2025

      August 11, 2025

      I found a Google Maps alternative that won’t track you or drain your battery – and it’s free

      August 12, 2025

      I tested this new AI podcast tool to see if it can beat NotebookLM – here’s how it did

      August 12, 2025

      Microsoft’s new update makes your taskbar a productivity hub – here’s how

      August 12, 2025

      Save $50 on the OnePlus Pad 3 plus get a free gift – here’s the deal

      August 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Laravel Global Scopes: Automatic Query Filtering

      August 12, 2025
      Recent

      Laravel Global Scopes: Automatic Query Filtering

      August 12, 2025

      Building MCP Servers in PHP

      August 12, 2025

      Filament v4 is Stable!

      August 12, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      I Asked OpenAI’s New Open-Source AI Model to Complete a Children’s School Test — Is It Smarter Than a 10-Year-Old?

      August 12, 2025
      Recent

      I Asked OpenAI’s New Open-Source AI Model to Complete a Children’s School Test — Is It Smarter Than a 10-Year-Old?

      August 12, 2025

      Madden NFL 26 Leads This Week’s Xbox Drops—But Don’t Miss These Hidden Gems

      August 12, 2025

      ASUS G14 Bulked Up for 2025—Still Sexy, Just a Bit Chonkier

      August 12, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Exactly a Date

    CodeSOD: Exactly a Date

    May 13, 2025

    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!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleCVE-2025-26662 – Apache Data Services Management Console Cross-Site Scripting Vulnerability
    Next Article nip4 is an image processing spreadsheet

    Related Posts

    News & Updates

    I found a Google Maps alternative that won’t track you or drain your battery – and it’s free

    August 12, 2025
    News & Updates

    I tested this new AI podcast tool to see if it can beat NotebookLM – here’s how it did

    August 12, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Microsoft Offers Windows 11 to PCs That Shouldn’t Get It

    Operating Systems

    CVE-2025-55188 – 7-Zip Symbolic Link Extraction Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-7816 – PHPGurukul Apartment Visitors Management System Cross-Site Scripting Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Samsung’s house robot Ballie will have Google Cloud’s generative AI built in

    News & Updates

    Highlights

    CVE-2025-6372 – D-Link DIR-619L Stack-Based Buffer Overflow Vulnerability

    June 20, 2025

    CVE ID : CVE-2025-6372

    Published : June 20, 2025, 11:15 p.m. | 1 hour, 44 minutes ago

    Description : A vulnerability, which was classified as critical, was found in D-Link DIR-619L 2.06B01. This affects the function formSetWizard1 of the file /goform/formSetWizard1. The manipulation of the argument curTime leads to stack-based buffer overflow. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used. This vulnerability only affects products that are no longer supported by the maintainer.

    Severity: 8.8 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    FilamentExamples.com: Our Demo-Projects and Tutorials on Filament

    June 9, 2025

    Modern async iteration in JavaScript with Array.fromAsync()

    July 14, 2025

    U.S. Sanctions Funnull for $200M Romance Baiting Scams Tied to Crypto Fraud

    May 30, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.