diff --git a/.gitignore b/.gitignore index affa4d2..a545b21 100644 --- a/.gitignore +++ b/.gitignore @@ -109,4 +109,5 @@ Backup*/ UpgradeLog*.XML # Debug Data Directories -App_Data \ No newline at end of file +App_Data +.cr/ \ No newline at end of file diff --git a/NodaTime.CurrentTzdbProvider/NodaTime.CurrentTzdbProvider.csproj b/NodaTime.CurrentTzdbProvider/NodaTime.CurrentTzdbProvider.csproj index a161f59..2f13c4c 100644 --- a/NodaTime.CurrentTzdbProvider/NodaTime.CurrentTzdbProvider.csproj +++ b/NodaTime.CurrentTzdbProvider/NodaTime.CurrentTzdbProvider.csproj @@ -9,8 +9,9 @@ Properties NodaTime NodaTime.CurrentTzdbProvider - v4.5 + v4.7.2 512 + true @@ -30,8 +31,8 @@ 4 - - ..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll + + ..\packages\NodaTime.3.0.5\lib\netstandard2.0\NodaTime.dll @@ -43,6 +44,9 @@ ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + diff --git a/NodaTime.CurrentTzdbProvider/packages.config b/NodaTime.CurrentTzdbProvider/packages.config index ae8a285..2fed9f6 100644 --- a/NodaTime.CurrentTzdbProvider/packages.config +++ b/NodaTime.CurrentTzdbProvider/packages.config @@ -3,5 +3,6 @@ - + + \ No newline at end of file diff --git a/SqlTzLoader/Program.cs b/SqlTzLoader/Program.cs index 9d074e0..9f207b6 100644 --- a/SqlTzLoader/Program.cs +++ b/SqlTzLoader/Program.cs @@ -14,18 +14,15 @@ class Program { private static Options _options = new Options(); - static void Main(string[] args) + + static async Task Main(string[] args) { if (CommandLine.Parser.Default.ParseArgumentsStrict(args, _options)) { if (_options.Verbose) Console.WriteLine("ConnectionString: {0}", _options.ConnectionString); - - AsyncPump.Run(() => MainAsync(args)); - } - } - static async Task MainAsync(string[] args) - { + } + var tzdb = await CurrentTzdbProvider.LoadAsync(); var zones = await WriteZonesAsync(tzdb.Ids); @@ -35,6 +32,20 @@ static async Task MainAsync(string[] args) await WriteIntervalsAsync(zones, tzdb); await WriteVersion(tzdb.VersionId.Split(' ')[1]); + + await ExtendFinalIntervalToEndOfTime(); + } + static async Task ExtendFinalIntervalToEndOfTime() + { + Console.Write("Extending final intervals to end of time"); + var cs = _options.ConnectionString; + using (var connection = new SqlConnection(cs)) + { + await connection.OpenAsync(); + var command = new SqlCommand("update tzdb.intervals set utcend='9999-12-31 23:59:59', localend='9999-12-31 23:59:59' where utcend > '2026-02-08 07:00:00' and utcend <> '9999-12-31 23:59:59'", connection); + await command.ExecuteNonQueryAsync(); + connection.Close(); + } } private static async Task> WriteZonesAsync(IEnumerable zones) @@ -90,7 +101,7 @@ private static async Task WriteLinksAsync(IDictionary zones, ILooku private static async Task WriteIntervalsAsync(IDictionary zones, CurrentTzdbProvider tzdb) { - var currentUtcYear = SystemClock.Instance.Now.InUtc().Year; + var currentUtcYear = SystemClock.Instance.GetCurrentInstant().InUtc().Year; var maxYear = currentUtcYear + 5; var maxInstant = new LocalDate(maxYear + 1, 1, 1).AtMidnight().InUtc().ToInstant(); @@ -115,11 +126,11 @@ private static async Task WriteIntervalsAsync(IDictionary zones, Cu foreach (var interval in intervals) { - var utcStart = interval.Start == Instant.MinValue + var utcStart = !interval.HasStart ? DateTime.MinValue : interval.Start.ToDateTimeUtc(); - var utcEnd = interval.End == Instant.MaxValue + var utcEnd = !interval.HasEnd ? DateTime.MaxValue : interval.End.ToDateTimeUtc(); @@ -147,6 +158,7 @@ private static async Task WriteIntervalsAsync(IDictionary zones, Cu dt.Rows.Add(utcStart, utcEnd, localStart, localEnd, offsetMinutes, abbreviation); } + if (_options.Verbose) Console.WriteLine("Processing: {0}", id); var cs = _options.ConnectionString; using (var connection = new SqlConnection(cs)) diff --git a/SqlTzLoader/SqlTzLoader.csproj b/SqlTzLoader/SqlTzLoader.csproj index d26d101..522a867 100644 --- a/SqlTzLoader/SqlTzLoader.csproj +++ b/SqlTzLoader/SqlTzLoader.csproj @@ -9,8 +9,9 @@ Properties SqlTzLoader SqlTzLoader - v4.5 + v4.7.2 512 + AnyCPU @@ -36,13 +37,16 @@ ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll True - - ..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll + + ..\packages\NodaTime.3.0.5\lib\netstandard2.0\NodaTime.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + @@ -52,6 +56,7 @@ + diff --git a/SqlTzLoader/app.config b/SqlTzLoader/app.config new file mode 100644 index 0000000..312bb3f --- /dev/null +++ b/SqlTzLoader/app.config @@ -0,0 +1,3 @@ + + + diff --git a/SqlTzLoader/packages.config b/SqlTzLoader/packages.config index cd2e889..8f209da 100644 --- a/SqlTzLoader/packages.config +++ b/SqlTzLoader/packages.config @@ -1,5 +1,6 @@  - + + \ No newline at end of file