<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: cdilorenzo</title>
    <description>The latest articles on Forem by cdilorenzo (@cdilorenzo).</description>
    <link>https://forem.com/cdilorenzo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3251191%2F3ebe90ac-5180-4477-8e05-6e6fd393e902.png</url>
      <title>Forem: cdilorenzo</title>
      <link>https://forem.com/cdilorenzo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cdilorenzo"/>
    <language>en</language>
    <item>
      <title>⏱️ Stop Parsing Durations by Hand — Meet SmartTimeSpanParser for .NET 9</title>
      <dc:creator>cdilorenzo</dc:creator>
      <pubDate>Mon, 09 Jun 2025 10:07:54 +0000</pubDate>
      <link>https://forem.com/cdilorenzo/stop-parsing-durations-by-hand-meet-smarttimespanparser-for-net-9-30cj</link>
      <guid>https://forem.com/cdilorenzo/stop-parsing-durations-by-hand-meet-smarttimespanparser-for-net-9-30cj</guid>
      <description>&lt;p&gt;Tired of writing boilerplate code to parse time durations like "2h 30m" or "1.5 days" into TimeSpan objects?&lt;br&gt;
You're not alone. That's why I created:&lt;/p&gt;

&lt;p&gt;👉 SmartTimeSpanParser&lt;/p&gt;

&lt;p&gt;A small but powerful .NET library that converts natural language time durations into native TimeSpan values.&lt;/p&gt;




&lt;p&gt;💡 Why This Library?&lt;/p&gt;

&lt;p&gt;We’ve all been there:&lt;/p&gt;

&lt;p&gt;TimeSpan.FromHours(2.5); // Cool. But what if the input is "2h 30m"?&lt;/p&gt;

&lt;p&gt;Parsing text inputs from config files, CLI args, or user interfaces usually leads to ugly regex and a bunch of if-else spaghetti. With SmartTimeSpanParser, you write:&lt;/p&gt;

&lt;p&gt;var span = SmartTimeSpan.Parse("1h 15m"); // ⏱️ 01:15:00&lt;/p&gt;

&lt;p&gt;And you’re done.&lt;/p&gt;




&lt;p&gt;🚀 Features&lt;/p&gt;

&lt;p&gt;✅ Parses common formats like:&lt;/p&gt;

&lt;p&gt;2h, 30m, 1.5 days, 90s&lt;/p&gt;

&lt;p&gt;1h 30m, 2d 3h&lt;/p&gt;

&lt;p&gt;✅ Returns native TimeSpan&lt;/p&gt;

&lt;p&gt;✅ Supports TryParse&lt;/p&gt;

&lt;p&gt;✅ Zero dependencies — just plug &amp;amp; play&lt;/p&gt;

&lt;p&gt;✅ Targeting .NET 9 💪&lt;/p&gt;




&lt;p&gt;📦 Install via NuGet&lt;/p&gt;

&lt;p&gt;dotnet add package SmartTimeSpanParser&lt;/p&gt;




&lt;p&gt;✅ Example Usage&lt;/p&gt;

&lt;p&gt;var duration = SmartTimeSpan.Parse("2d 4h 15m");&lt;/p&gt;

&lt;p&gt;Console.WriteLine(duration); // 52:15:00&lt;/p&gt;

&lt;p&gt;Need to validate input safely?&lt;/p&gt;

&lt;p&gt;if (SmartTimeSpan.TryParse("45 minutes", out var result))&lt;br&gt;
{&lt;br&gt;
    Console.WriteLine(result); // 00:45:00&lt;br&gt;
}&lt;/p&gt;




&lt;p&gt;🛠️ What's Next?&lt;/p&gt;

&lt;p&gt;Coming soon:&lt;/p&gt;

&lt;p&gt;ToHumanString() → Turn TimeSpan back into "2h 30m"&lt;/p&gt;

&lt;p&gt;Localization support (de, fr, es)&lt;/p&gt;

&lt;p&gt;CLI tool&lt;/p&gt;

&lt;p&gt;Milliseconds support&lt;/p&gt;




&lt;p&gt;🤝 Contributors Welcome&lt;/p&gt;

&lt;p&gt;Have a cool idea? Found a missing edge case?&lt;br&gt;
Open a PR or an issue here:&lt;br&gt;
👉 &lt;a href="https://github.com/cdilorenzo/SmartTimeSpanParser" rel="noopener noreferrer"&gt;https://github.com/cdilorenzo/SmartTimeSpanParser&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;🧪 Fully Tested&lt;/p&gt;

&lt;p&gt;With full test coverage using xUnit, you can trust it in production.&lt;/p&gt;




&lt;p&gt;⭐ Support the Project&lt;/p&gt;

&lt;p&gt;If you find this library useful:&lt;/p&gt;

&lt;p&gt;➡️ Give it a ⭐ on GitHub&lt;br&gt;
➡️ Share it with your developer friends&lt;br&gt;
➡️ Use it in your next project!&lt;/p&gt;




&lt;p&gt;Let me know what you think — I’d love feedback or ideas for future improvements!&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop parsing “last 3 business days” by hand — I built a fluent date range parser for .NET</title>
      <dc:creator>cdilorenzo</dc:creator>
      <pubDate>Sat, 07 Jun 2025 13:28:25 +0000</pubDate>
      <link>https://forem.com/cdilorenzo/stop-parsing-last-3-business-days-by-hand-i-built-a-fluent-date-range-parser-for-net-5142</link>
      <guid>https://forem.com/cdilorenzo/stop-parsing-last-3-business-days-by-hand-i-built-a-fluent-date-range-parser-for-net-5142</guid>
      <description>&lt;p&gt;How many times have you written code like this? 👇&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
csharp
var today = DateTime.Today;
var start = today.AddDays(-7);

while (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday)
    start = start.AddDays(-1);

Just to figure out what “last 3 business days” means? I got tired of it, so I built this:

var range = SmartDateRange.Parse("last 3 business days");

Console.WriteLine(range.Start); // e.g. 2024-05-29
Console.WriteLine(range.End);   // e.g. 2024-05-31

✅ Supports:

"today", "yesterday"

"last N days"

"last N business days"

"this week", "this month"

And more, with TryParse support for safe usage



---

🔍 Why I Built It

I was working on a reporting dashboard and found that:

Existing libraries were either too heavy (NLP, ML-based)

Or too manual (lots of repetitive date math)


So I built something focused, lightweight, and fluent — no external dependencies, just solid .NET 9.


---

🚀 Features

✅ Fluent API: SmartDateRange.Parse("this week")

✅ TryParse() fallback to avoid exceptions

✅ Easy to integrate into LINQ filters or APIs

✅ Culture-ready (localization support incoming)



---

🧪 Try It

You can grab the package from GitHub:

📦 GitHub: https://github.com/cdilorenzo/SmartDateRangeParser
(Coming soon to NuGet!)


---

🤝 Contribute or Give Feedback

Pull requests welcome

Feature requests encouraged

⭐ Stars appreciated if you find it useful


Let me know what use case you'd like to see supported next!


---

🧠 Built with ❤️ by @cdilorenzo

---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
