Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TimeZoneNotFoundException #18

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

fernandolguevara
Copy link
Contributor

@fernandolguevara fernandolguevara commented Mar 23, 2018

Fix #17 throws TimeZoneNotFoundException when call GetTimeZoneInfo("UTC")

Fix throws TimeZoneNotFoundException when call GetTimeZoneInfo("UTC")
@mattjohnsonpint
Copy link
Owner

mattjohnsonpint commented Mar 27, 2018

Thanks, but it's odd this needs special handling. "UTC" is valid for both IANA and Windows. Is there something special about why this doesn't work as is on Mac?

@fernandolguevara
Copy link
Contributor Author

@mj1856

below is the source code of TimeZoneInfo for operative systems based on unix, so, there is a special consideration for "UTC" id

   public static TimeZoneInfo FindSystemTimeZoneById(string id)
        {
            // Special case for Utc as it will not exist in the dictionary with the rest
            // of the system time zones.  There is no need to do this check for Local.Id
            // since Local is a real time zone that exists in the dictionary cache
            if (string.Equals(id, UtcId, StringComparison.OrdinalIgnoreCase))
            {
                return Utc;
            }
           .....

@fernandolguevara
Copy link
Contributor Author

@mj1856 another possible solution could be adding TimeZoneInfo.Utc to the SystemTimeZones dictionary

@mattjohnsonpint
Copy link
Owner

Makes sense. Thanks!

@mattjohnsonpint mattjohnsonpint merged commit 2e8b67d into mattjohnsonpint:master Mar 27, 2018
mattjohnsonpint added a commit that referenced this pull request Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants