Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Update to latest Noda and .NET 4.7.2 #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@ Backup*/
UpgradeLog*.XML

# Debug Data Directories
App_Data
App_Data
.cr/
10 changes: 7 additions & 3 deletions NodaTime.CurrentTzdbProvider/NodaTime.CurrentTzdbProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NodaTime</RootNamespace>
<AssemblyName>NodaTime.CurrentTzdbProvider</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -30,8 +31,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NodaTime">
<HintPath>..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath>
<Reference Include="NodaTime, Version=3.0.5.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.3.0.5\lib\netstandard2.0\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -43,6 +44,9 @@
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion NodaTime.CurrentTzdbProvider/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net45" />
<package id="NodaTime" version="1.3.1" targetFramework="net45" />
<package id="NodaTime" version="3.0.5" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net472" />
</packages>
32 changes: 22 additions & 10 deletions SqlTzLoader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<IDictionary<string, int>> WriteZonesAsync(IEnumerable<string> zones)
Expand Down Expand Up @@ -90,7 +101,7 @@ private static async Task WriteLinksAsync(IDictionary<string, int> zones, ILooku

private static async Task WriteIntervalsAsync(IDictionary<string, int> 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();

Expand All @@ -115,11 +126,11 @@ private static async Task WriteIntervalsAsync(IDictionary<string, int> 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();

Expand Down Expand Up @@ -147,6 +158,7 @@ private static async Task WriteIntervalsAsync(IDictionary<string, int> 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))
Expand Down
11 changes: 8 additions & 3 deletions SqlTzLoader/SqlTzLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SqlTzLoader</RootNamespace>
<AssemblyName>SqlTzLoader</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -36,13 +37,16 @@
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NodaTime">
<HintPath>..\packages\NodaTime.1.3.1\lib\net35-Client\NodaTime.dll</HintPath>
<Reference Include="NodaTime, Version=3.0.5.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\NodaTime.3.0.5\lib\netstandard2.0\NodaTime.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
Expand All @@ -52,6 +56,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions SqlTzLoader/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
3 changes: 2 additions & 1 deletion SqlTzLoader/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="NodaTime" version="1.3.1" targetFramework="net45" />
<package id="NodaTime" version="3.0.5" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net472" />
</packages>