Skip to content

Instantly share code, notes, and snippets.

@EifelMono
Last active August 5, 2021 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EifelMono/23496a34257bf2ff5f75872c1becec80 to your computer and use it in GitHub Desktop.
Save EifelMono/23496a34257bf2ff5f75872c1becec80 to your computer and use it in GitHub Desktop.
dotnet Core, 5,0, 6.0 Date parsing with 2 year digits ......... 00-29 => 2000-2229 but 30-99=>1930-1999
using System;
using System.Globalization;
class Program
{
static void Main(string[] args)
{
for (var year = 20; year < 40; year++)
if (DateTime.TryParseExact($"{year:00}0101", "yyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var date))
Console.WriteLine($"[{year:00} = {date.Year:0000}] {year:00}0101 = {date:yyyy.MM.dd}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment