You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that ... with Win10 UWP, ITimeZoneEx.ConvertTime cause exception with some certain timezones and years. This issue does not occur with Desktop app.
I've wrote the small test code as below.`
string strout = "";
var allZones = TimeZoneService.AllTimeZones;
foreach (var zone in allZones)
{
string thisTzError = "";
int year = 1901;
int yearMax = 2099;
var tz = TimeZoneService.FindSystemTimeZoneById(zone.Id);
while (year < yearMax)
{
DateTimeOffset timeOffset = new DateTimeOffset(new DateTime(year, 4, 1));
try
{
tz.ConvertTime(timeOffset);
}
catch (Exception ex)
{
thisTzError = thisTzError + timeOffset.ToString("yyyy") + " ";
}
year = year + 1;
}
if (!string.IsNullOrEmpty(thisTzError))
{
strout = strout + zone.Id + ", " + thisTzError + "\n";
}
}`
If you run the code at UWP app, the result is following. If the app is WinForms desktop, nothing happen.
Central Brazilian Standard Time, 2007
Chatham Islands Standard Time, 2017 2023 2028 2034 2045 2051 2056 2062 2073 2079 2084 2090
E. South America Standard Time, 2007
Egypt Standard Time, 1903 1908 1914 1925 1931 1936 1942 1953 1959 1964 1970 1981 1987 1992 1998 2008
Magadan Standard Time, 2016
Mid-Atlantic Standard Time, 1905 1911 1916 1922 1933 1939 1944 1950 1961 1967 1972 1978 1989 1995 2000 2006 2017 2023 2028 2034 2045 2051 2056 2062 2073 2079 2084 2090
New Zealand Standard Time, 2017 2023 2028 2034 2045 2051 2056 2062 2073 2079 2084 2090
Samoa Standard Time, 2017 2023 2028 2034 2045 2051 2056 2062 2073 2079 2084 2090
Syria Standard Time, 1903 1908 1914 1925 1931 1936 1942 1953 1959 1964 1970 1981 1987 1992 1998
Ulaanbaatar Standard Time, 2021 2027 2032 2038 2049 2055 2060 2066 2077 2083 2088 2094
W. Mongolia Standard Time, 1904 1910 1921 1927 1932 1938 1949 1955 1960 1966 1977 1983 1988 1994 2005 2021 2027 2032 2038 2049 2055 2060 2066 2077 2083 2088 2094
I've tried to debug it, and I could identify the point but I have no idea to solve it.
It seems that... the method IsDaylightTime call the method FindTimeZoneData ( line 153 at TimeZones.WinRT.Shared/Internal/TimeZoneInfoEx.cs ).
At the error case, this method - FindTimeZoneData - generate the invalid date like as 31-Feb or 31-Sept. This invalid data cause the exception at the end of this method.
The text was updated successfully, but these errors were encountered:
@calbot , No. My project that use this package is old one, maintenance mode. So I've put an exception handler and have apologized for users. 😢
If I have a chance, I'll rewrite my code to use the NodaTime.
I would suggest moving to the built-in TimeZoneInfo class for this. It's available on the platforms now, so this library doesn't need to exist anymore.
I found that ... with Win10 UWP, ITimeZoneEx.ConvertTime cause exception with some certain timezones and years. This issue does not occur with Desktop app.
I've wrote the small test code as below.`
If you run the code at UWP app, the result is following. If the app is WinForms desktop, nothing happen.
I've tried to debug it, and I could identify the point but I have no idea to solve it.
It seems that... the method IsDaylightTime call the method FindTimeZoneData ( line 153 at TimeZones.WinRT.Shared/Internal/TimeZoneInfoEx.cs ).
At the error case, this method - FindTimeZoneData - generate the invalid date like as 31-Feb or 31-Sept. This invalid data cause the exception at the end of this method.
The text was updated successfully, but these errors were encountered: