lzorglub / timezone Goto Github PK
View Code? Open in Web Editor NEWAlternative to Windows .Net timezone
License: GNU General Public License v2.0
Alternative to Windows .Net timezone
License: GNU General Public License v2.0
I was trying to investigate an issue reported here: http://mm.icann.org/pipermail/tz/2018-July/026698.html
I decided to implement a tzvalidate dump for Afk.TimeZone, but in doing so I found a problem that it's hard to get past.
The "America/Argentina/Buenos_Aires" time zone seems to get "stuck" for at least some time at 1998-12-31T23:56:15Z. Here's a program to demonstrate:
using System;
using System.Linq;
using Afk.ZoneInfo;
class Program
{
static void Main(string[] args)
{
var zone = TzTimeInfo.GetZones().Single(z => z.Name == "America/Argentina/Buenos_Aires");
var start = new DateTime(1998, 12, 31, 23, 56, 15, DateTimeKind.Utc);
for (int i = 0; i < 10; i++)
{
Console.WriteLine(zone.ToLocalTime(start.AddTicks(i)).Ticks);
}
}
}
The output is:
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
630507345750000000
That basically suggests that the wall clock stands still for at least those 10 ticks, which shouldn't happen.
I'm going to try to hard-code a workaround for this to start with, but it's not clear whether that will be sufficient.
Values provided for America/Grand_Turk year 2018 are incorrect.
The optimized algorithm (prefetch of DST changes) retrieve the wrong DST value.
Version 2.2 use now by default the normal algorithm before fix.
When I download the files manually, I get an exception. "The type initializer for 'Afk.ZoneInfo.TzTimeInfo' threw an exception."
I looked at it a little in the debugger and it seems there is some duplicate key error. BTW, it seems that it happens even with the current files. I copied the current files in the data folder to another folder and defined that folder in the env var TZDIR and the same thing happens.
Just to be clear, I just download https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz and unpack it into a directory. That is my TZDIR.
For some dates,when i convert local tome to utc and reverse utc to local,then local dates aren't same.
this is my test that reproduce the bug:
[TestMethod]
public void ToUtcAndReverse()
{
var timeZoneProvider = new AfkTimeZoneProvider();
const string IranStandardTime = "Iran Standard Time";
var errors = new List<string>();
var currentDate = new DateTime(1940, 1, 1);
var maxDate = new DateTime(2040, 1, 1);
for (var i = 1; i < 10000000; i++)
{
var utcDate = timeZoneProvider.ToUtc(currentDate, IranStandardTime);
var localDate = timeZoneProvider.ToLocal(utcDate, IranStandardTime);
if (currentDate.Date != localDate.Date)
{
errors.Add(currentDate.ToLongDateString());
}
currentDate = currentDate.AddDays(1);
if (currentDate > maxDate)
{
break;
}
}
if (errors.Any())
{
Assert.Fail();
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.