From: Egor Bogatov Date: Thu, 1 Nov 2018 21:13:10 +0000 (+0300) Subject: Display offset in TimeZoneInfo.DisplayName (#20728) X-Git-Tag: accepted/tizen/unified/20190422.045933~841 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5608a7d68fc6271a1ee3d86291222c1620e40c7;p=platform%2Fupstream%2Fcoreclr.git Display offset in TimeZoneInfo.DisplayName (#20728) * Display offset in TimeZoneInfo.DisplayInfo * Display offset in TimeZoneInfo.DisplayInfo * prefer +00.00 * Update TimeZoneInfo.Unix.cs --- diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs index 5645c2a..ebeb301 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs @@ -80,6 +80,14 @@ namespace System GetDisplayName(Interop.Globalization.TimeZoneDisplayNameType.Standard, ref _standardDisplayName); GetDisplayName(Interop.Globalization.TimeZoneDisplayNameType.DaylightSavings, ref _daylightDisplayName); + if (_standardDisplayName == _displayName) + { + if (_baseUtcOffset >= TimeSpan.Zero) + _displayName = $"(UTC+{_baseUtcOffset:hh\\:mm}) {_standardDisplayName}"; + else + _displayName = $"(UTC-{_baseUtcOffset:hh\\:mm}) {_standardDisplayName}"; + } + // TZif supports seconds-level granularity with offsets but TimeZoneInfo only supports minutes since it aligns // with DateTimeOffset, SQL Server, and the W3C XML Specification if (_baseUtcOffset.Ticks % TimeSpan.TicksPerMinute != 0)