The .NET Stacks #54: 🎀 Putting a bow on .NET 6 date and time updates

This week, we finish talking about date and time improvements that are coming with the .NET 6 release.

Dave Brock
Dave Brock

NOTE: This is the web version of my weekly newsletter, released on June 14, 2021. To get the issues right away, subscribe at or the bottom of this post.

Happy Monday! Here's what's going on this week:

  • The big thing: Putting a bow on .NET 6 date and time updates
  • The little things: Have I Been Pwned project updates, VS Code remote repositories extension, App Service support on .NET 6, Azure Functions updates
  • Last week in the .NET world

The big thing: Putting a bow on .NET 6 date and time updates

In a previous issue, we briefly spent some time exploring the new date and time APIs in .NET 6. (Despite feedback of the cringy title, I stand behind DateTime might be seeing other people.) In these posts, I passed along the information from various GitHub issues. This week, it was nice to see Matt Johnson-Pint officially write about it in detail on the .NET Blog.

Here's the gist: the .NET team is rolling out new DateOnly and TimeOnly types for .NET 6.

The DateOnly type, if you can believe it, only supports a date—like a year or a month. You might want to use this when you don't need an associated time, like birthdays and anniversaries. With DateOnly Microsoft promises better type safety when you only want dates, serialization improvements, and simplicity when interacting with databases. DateOnly ships with a robust constructor but no deconstructor.

As for TimeOnly, you'd use it only to represent a time of day. Potential use cases are alarm clock times, when a business is open, or recurring appointment times. Why not TimeSpan? Here, TimeOnly is intended for a time of day and not elapsed time. Again, you'll gain type safety and more accuracy when calculating ranges.

There's a lot of chatter in the community asking: why not use Noda Time instead? From the post:

Noda Time is a great example of a high-quality, community developed .NET open source library ... However, we didn’t feel that implementing a Noda-like API in .NET itself was warranted. After careful evaluation, it was decided that it would be better to augment the existing types to fill in the gaps rather than to overhaul and replace them. After all, there are many .NET applications built using the existing DateTime, DateTimeOffset, TimeSpan, and TimeZoneInfo types. The DateOnly and TimeOnly types should feel natural to use along side them.

As an FYI, the new structs aren't supported in Entity Framework Core 6 yet, but you can check out this comment to find a relevant tracking issue. You'll want to check out the post—in addition to the new DateOnly and TimeOnly structs, the .NET team is rolling out time zone enhancements as well.

These changes aren't replacing any DateTime APIs, just augmenting them. So when it comes time for you to switch to .NET 6, do what works for you.

The little things: Have I Been Pwned project updates, VS Code remote repositories extension, Azure Functions updates, App Service support on .NET 6

This week, we'll talk about Have I Been Pwned, a new Visual Studio Code extension, and updates on running Azure Functions and Azure App Service updates on .NET 6.

Have I Been Pwned project updates

You've likely heard of Troy Hunt's Have I Been Pwned project. At the risk of oversimplifying all that Troy does, you can use it to check if your personal data has been compromised by data breaches. With the help of Cloudflare and Azure Functions, he's been able to operate at a tremendous scale with minimum cost. That site is now getting around 1 billion requests a month.

Last August, Troy announced his plans to take HIBP to open source. Recently, Troy wrote that the Pwned Passwords component is now a .NET Foundation project.  You can check out the code at the HaveIBeenPwned organization on GitHub. As a .NET developer, it's a nice way to look at the code and how it all works, especially when it comes to getting hashes and anonymizing requests.

VS Code remote repositories extension

In this space last week, we mentioned a new VS Code extension for Project Tye. Visual Studio Code is at it again with a new Remote Repositories extension. With this extension, you can browse, search, edit, and commit to any remote GitHub repository without a clone. This extension will support Azure DevOps soon as well. (GitHub is the long-term vision, yet Microsoft is consistently releasing these new capabilities to Azure DevOps. For this and other reasons, I'm pretty sure Azure DevOps will outlive me.)

Personally, looking at GitHub repos is good for my learning—both for what to do and what not to do—and there should be a middle ground between browsing and cloning a big repository to my machine. This should help.

Azure Functions updates

Last week, Azure Functions PM Anthony Chu wrote about recent Azure Functions updates. (I'll be interviewing him soon here, so hit me up if you have any other questions.) We've written about some of what he mentioned, but not everything—here's the latest.

  • Visual Studio support for .NET 5.0 isolated function apps: Released in May, Visual Studio 2019 16.10 includes full support for .NET 5.0 isolated process Azure Functions apps. You can check out the tutorial.
  • You can run .NET 6 on Azure Functions: To do this, you'll need Azure Functions V4—right now, it's limited to a preview release of Azure Functions Core Tools V4. Check out the post, as there are a few caveats to keep in mind. It's early, and there's no official support yet. Microsoft has published a tutorial on writing .NET 6 apps on Azure Functions.

Azure App Service support on .NET 6

In somewhat related Azure development news, you can use .NET 6 Preview bits on Azure App Service—in either Windows or Linux workloads. You can do this through the Azure App Service Early Access Runtime feature. This feature allows you to get the latest version of SDKs for various languages. With Early Access Runtime, you can get access without waiting for a release cycle.

Microsoft is boasting that it's the first time a pre-release stack is publicly available on App Service before the GA release.

🌎 Last week in the .NET world

We've got another busy week with some great content from the developer community.

🔥 The Top 5

📅 Community and events

🌎 Web development

🥅 The .NET platform

⛅ The cloud

📔 Languages

🔧 Tools

🏗 Design, testing, and best practices

🎤 Podcasts

🎥 Videos

.NET Stacks