Last active
August 5, 2021 21:11
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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