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

      How AI further empowers value stream management

      June 27, 2025

      12 Top ReactJS Development Companies in 2025

      June 27, 2025

      Not sure where to go with AI? Here’s your roadmap.

      June 27, 2025

      This week in AI dev tools: A2A donated to Linux Foundation, OpenAI adds Deep Research to API, and more (June 27, 2025)

      June 27, 2025

      With Gears of War: Reloaded on the way, which Xbox 360 game would you like to see get rebuilt next? β€” Weekend discussion πŸ’¬

      June 28, 2025

      Capcom’s finally giving Street Fighter 6 players the outfits they’ve wanted β€” when all else fails, send in swimsuits

      June 28, 2025

      After 14 years, Monster Hunter Wilds is bringing back underwater combat alongside “Lagiacrus” and another familiar monster β€” the impossible has happened

      June 28, 2025

      OpenAI may prematurely declare AGI to cut ties with Microsoft β€” despite Sam Altman admitting today’s tech isn’t built for it

      June 28, 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

      How Code Feedback MCP Enhances AI-Generated Code Quality

      June 28, 2025
      Recent

      How Code Feedback MCP Enhances AI-Generated Code Quality

      June 28, 2025

      PRSS Site Creator – Create Blogs and Websites from Your Desktop

      June 28, 2025

      Say hello to ECMAScript 2025

      June 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      With Gears of War: Reloaded on the way, which Xbox 360 game would you like to see get rebuilt next? β€” Weekend discussion πŸ’¬

      June 28, 2025
      Recent

      With Gears of War: Reloaded on the way, which Xbox 360 game would you like to see get rebuilt next? β€” Weekend discussion πŸ’¬

      June 28, 2025

      Jasmine – web launcher and session management application

      June 28, 2025

      Schulrechner – calculator you know from school

      June 28, 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

    With Gears of War: Reloaded on the way, which Xbox 360 game would you like to see get rebuilt next? β€” Weekend discussion πŸ’¬

    June 28, 2025
    News & Updates

    Capcom’s finally giving Street Fighter 6 players the outfits they’ve wanted β€” when all else fails, send in swimsuits

    June 28, 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

    CVE-2025-4145 – Netgear EX6200 Remote Buffer Overflow

    Common Vulnerabilities and Exposures (CVEs)

    Lenovo’s new 16-inch Yoga 7i doesn’t get the “2-in-1” part quite right, but there are some redeeming qualities here

    News & Updates

    Field Monitor is a remote desktop client designed for GNOME

    Linux

    CVE-2025-43860 – OpenEMR Stored Cross-Site Scripting (XSS) Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-49275 – Blogbyte PHP Remote File Inclusion Vulnerability

    June 9, 2025

    CVE ID : CVE-2025-49275

    Published : June 9, 2025, 4:15 p.m. | 25Β minutes ago

    Description : Improper Control of Filename for Include/Require Statement in PHP Program (‘PHP Remote File Inclusion’) vulnerability in Unfoldwp Blogbyte allows PHP Local File Inclusion. This issue affects Blogbyte: from n/a through 1.1.1.

    Severity: 8.1 | HIGH

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

    Google Introduces Open-Source Full-Stack AI Agent Stack Using Gemini 2.5 and LangGraph for Multi-Step Web Search, Reflection, and Synthesis

    June 8, 2025

    Play ransomware exploited Windows logging flaw in zero-day attacks

    May 7, 2025

    CVE-2025-25207 – Red Hat Connectivity Link Authorino Denial of Service

    June 9, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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