diff options
author | Tarek Mahmoud Sayed <tarekms@microsoft.com> | 2016-11-11 15:46:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-11 15:46:47 -0800 |
commit | 38b1f672caeb8f01aa2970c02c06b4ae7fcf06c4 (patch) | |
tree | ac87903adfa72639f876ad3bce1b7fd0e5f9d093 /src | |
parent | 17b820f470b22f0d8b8d5cb91257bac2b0bee5b4 (diff) | |
download | coreclr-38b1f672caeb8f01aa2970c02c06b4ae7fcf06c4.tar.gz coreclr-38b1f672caeb8f01aa2970c02c06b4ae7fcf06c4.tar.bz2 coreclr-38b1f672caeb8f01aa2970c02c06b4ae7fcf06c4.zip |
Enable the rest if TimeZoneInfo APIs (#8096)
Diffstat (limited to 'src')
-rw-r--r-- | src/mscorlib/model.xml | 2 | ||||
-rw-r--r-- | src/mscorlib/src/System/TimeZoneInfo.cs | 21 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/mscorlib/model.xml b/src/mscorlib/model.xml index 46bab1e103..393a4bb26b 100644 --- a/src/mscorlib/model.xml +++ b/src/mscorlib/model.xml @@ -8449,11 +8449,9 @@ <Member Name="ConvertTime(System.DateTime,System.TimeZoneInfo)" /> <Member Name="ConvertTime(System.DateTime,System.TimeZoneInfo,System.TimeZoneInfo)" /> <Member Name="ConvertTime(System.DateTimeOffset,System.TimeZoneInfo)" /> -<!-- Need Linux Implementation <Member Name="ConvertTimeBySystemTimeZoneId(System.DateTime,System.String)" /> <Member Name="ConvertTimeBySystemTimeZoneId(System.DateTime,System.String,System.String)" /> <Member Name="ConvertTimeBySystemTimeZoneId(System.DateTimeOffset,System.String)" /> ---> <Member Name="ConvertTimeFromUtc(System.DateTime,System.TimeZoneInfo)" /> <Member Name="ConvertTimeToUtc(System.DateTime)" /> <Member Name="ConvertTimeToUtc(System.DateTime,System.TimeZoneInfo)" /> diff --git a/src/mscorlib/src/System/TimeZoneInfo.cs b/src/mscorlib/src/System/TimeZoneInfo.cs index 6d2852f267..e41c0bd0fa 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.cs @@ -724,22 +724,25 @@ namespace System { s_cachedData = new CachedData(); } -#if FEATURE_WIN32_REGISTRY // // ConvertTimeBySystemTimeZoneId - // // Converts the value of a DateTime object from sourceTimeZone to destinationTimeZone // - static public DateTimeOffset ConvertTimeBySystemTimeZoneId(DateTimeOffset dateTimeOffset, String destinationTimeZoneId) { + static public DateTimeOffset ConvertTimeBySystemTimeZoneId(DateTimeOffset dateTimeOffset, String destinationTimeZoneId) + { return ConvertTime(dateTimeOffset, FindSystemTimeZoneById(destinationTimeZoneId)); } - static public DateTime ConvertTimeBySystemTimeZoneId(DateTime dateTime, String destinationTimeZoneId) { + static public DateTime ConvertTimeBySystemTimeZoneId(DateTime dateTime, String destinationTimeZoneId) + { return ConvertTime(dateTime, FindSystemTimeZoneById(destinationTimeZoneId)); } - static public DateTime ConvertTimeBySystemTimeZoneId(DateTime dateTime, String sourceTimeZoneId, String destinationTimeZoneId) { - if (dateTime.Kind == DateTimeKind.Local && String.Compare(sourceTimeZoneId, TimeZoneInfo.Local.Id, StringComparison.OrdinalIgnoreCase) == 0) { + static public DateTime ConvertTimeBySystemTimeZoneId(DateTime dateTime, String sourceTimeZoneId, String destinationTimeZoneId) + { + if (dateTime.Kind == DateTimeKind.Local && String.Compare(sourceTimeZoneId, TimeZoneInfo.Local.Id, StringComparison.OrdinalIgnoreCase) == 0) + { // TimeZoneInfo.Local can be cleared by another thread calling TimeZoneInfo.ClearCachedData. // Take snapshot of cached data to guarantee this method will not be impacted by the ClearCachedData call. // Without the snapshot, there is a chance that ConvertTime will throw since 'source' won't @@ -748,7 +751,8 @@ namespace System { CachedData cachedData = s_cachedData; return ConvertTime(dateTime, cachedData.Local, FindSystemTimeZoneById(destinationTimeZoneId), TimeZoneInfoOptions.None, cachedData); } - else if (dateTime.Kind == DateTimeKind.Utc && String.Compare(sourceTimeZoneId, TimeZoneInfo.Utc.Id, StringComparison.OrdinalIgnoreCase) == 0) { + else if (dateTime.Kind == DateTimeKind.Utc && String.Compare(sourceTimeZoneId, TimeZoneInfo.Utc.Id, StringComparison.OrdinalIgnoreCase) == 0) + { // TimeZoneInfo.Utc can be cleared by another thread calling TimeZoneInfo.ClearCachedData. // Take snapshot of cached data to guarantee this method will not be impacted by the ClearCachedData call. // Without the snapshot, there is a chance that ConvertTime will throw since 'source' won't @@ -757,12 +761,11 @@ namespace System { CachedData cachedData = s_cachedData; return ConvertTime(dateTime, cachedData.Utc, FindSystemTimeZoneById(destinationTimeZoneId), TimeZoneInfoOptions.None, cachedData); } - else { + else + { return ConvertTime(dateTime, FindSystemTimeZoneById(sourceTimeZoneId), FindSystemTimeZoneById(destinationTimeZoneId)); } } -#endif // FEATURE_WIN32_REGISTRY - // // ConvertTime - |