c# - noda time iana mapping of Etc/UTC to Windows timezone -



c# - noda time iana mapping of Etc/UTC to Windows timezone -

i have global website passing iana timezone id server , using noda time map windows timezone in c# 5 web app.

"etc/utc" beingness passed server noda time can not map windows time zone. how can map iana timezone id?

public timezoneinfo gettimezonebyianaid(string ianatimezoneid) { tzdbdatetimezonesource timezonesource = tzdbdatetimezonesource.default; ilist<mapzone> zonemaps = timezonesource.windowsmapping.mapzones; // resolve link, since cldr doesn't utilize canonical ids ilist<string> mapzoneids = timezonesource.canonicalidmap.where(map => map.value.equals(ianatimezoneid, stringcomparison.ordinalignorecase)).select(x => x.key).tolist(); mapzone mapzone = zonemaps.firstordefault(zonemap => zonemap.tzdbids.any(mapzoneids.contains)); if (mapzone == null) { throw new timezonenotfoundexception("unable determine clients timezone using jstimezonedetect plugin"); } timezoneinfo timezone = timezoneinfo.findsystemtimezonebyid(mapzone.windowsid); if (timezone == null) { throw new timezonenotfoundexception("unable determine clients timezone nodatime"); } homecoming timezone; }

as jon pointed out, cldr mapping not there "etc/utc". instead, cldr maps windows "utc" time zone "etc/gmt". imho - in error.

the cldr requires "stable identifiers", has not traditionally updated mappings when time zone names change. instead, 1 follow "links" in time zone database map canonical zone.

however - tzdb doesn't consider "etc/gmt" link "etc/utc". 2 distinct zones. there's "etc/uct". applications rely on tzdb time zone abbreviations can utilize selection of abbreviation (gmt, utc, or uct). (see give-and-take here.)

anyway - reminding of problem. updated mapping functions take account.

c# nodatime

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -