summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEgor Bogatov <egorbo@gmail.com>2018-11-02 00:13:10 +0300
committerTarek Mahmoud Sayed <tarekms@microsoft.com>2018-11-01 14:13:10 -0700
commitd5608a7d68fc6271a1ee3d86291222c1620e40c7 (patch)
treef8b1578ccea03bd0961187da27122ba233f72fc1
parentb99629579eb4785e5fcf550d920a1e2d7b605be9 (diff)
downloadcoreclr-d5608a7d68fc6271a1ee3d86291222c1620e40c7.tar.gz
coreclr-d5608a7d68fc6271a1ee3d86291222c1620e40c7.tar.bz2
coreclr-d5608a7d68fc6271a1ee3d86291222c1620e40c7.zip
Display offset in TimeZoneInfo.DisplayName (#20728)
* Display offset in TimeZoneInfo.DisplayInfo * Display offset in TimeZoneInfo.DisplayInfo * prefer +00.00 * Update TimeZoneInfo.Unix.cs
-rw-r--r--src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs
index 5645c2a389..ebeb301fd1 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)