@@ -32,47 +32,6 @@ public sealed partial class TimeZoneInfo
32
32
33
33
private const string InvariantUtcStandardDisplayName = "Coordinated Universal Time" ;
34
34
35
- private sealed partial class CachedData
36
- {
37
- private static TimeZoneInfo GetCurrentOneYearLocal ( )
38
- {
39
- // load the data from the OS
40
- uint result = Interop . Kernel32 . GetTimeZoneInformation ( out TIME_ZONE_INFORMATION timeZoneInformation ) ;
41
- return result == Interop . Kernel32 . TIME_ZONE_ID_INVALID ?
42
- CreateCustomTimeZone ( LocalId , TimeSpan . Zero , LocalId , LocalId ) :
43
- GetLocalTimeZoneFromWin32Data ( timeZoneInformation , dstDisabled : false ) ;
44
- }
45
-
46
- private volatile OffsetAndRule ? _oneYearLocalFromUtc ;
47
-
48
- public OffsetAndRule GetOneYearLocalFromUtc ( int year )
49
- {
50
- OffsetAndRule ? oneYearLocFromUtc = _oneYearLocalFromUtc ;
51
- if ( oneYearLocFromUtc == null || oneYearLocFromUtc . Year != year )
52
- {
53
- TimeZoneInfo currentYear = GetCurrentOneYearLocal ( ) ;
54
- AdjustmentRule ? rule = currentYear . _adjustmentRules ? [ 0 ] ;
55
- oneYearLocFromUtc = new OffsetAndRule ( year , currentYear . BaseUtcOffset , rule ) ;
56
- _oneYearLocalFromUtc = oneYearLocFromUtc ;
57
- }
58
- return oneYearLocFromUtc ;
59
- }
60
- }
61
-
62
- private sealed class OffsetAndRule
63
- {
64
- public readonly int Year ;
65
- public readonly TimeSpan Offset ;
66
- public readonly AdjustmentRule ? Rule ;
67
-
68
- public OffsetAndRule ( int year , TimeSpan offset , AdjustmentRule ? rule )
69
- {
70
- Year = year ;
71
- Offset = offset ;
72
- Rule = rule ;
73
- }
74
- }
75
-
76
35
/// <summary>
77
36
/// Returns a cloned array of AdjustmentRule objects
78
37
/// </summary>
@@ -360,38 +319,10 @@ private static TimeZoneInfo GetLocalTimeZoneFromWin32Data(in TIME_ZONE_INFORMATI
360
319
private static TimeZoneInfoResult TryGetTimeZone ( string id , out TimeZoneInfo ? timeZone , out Exception ? e , CachedData cachedData )
361
320
=> TryGetTimeZone ( id , false , out timeZone , out e , cachedData ) ;
362
321
363
- // DateTime.Now fast path that avoids allocating an historically accurate TimeZoneInfo.Local and just creates a 1-year (current year) accurate time zone
364
- internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc ( DateTime time , out bool isAmbiguousLocalDst )
365
- {
366
- isAmbiguousLocalDst = false ;
367
-
368
- if ( Invariant )
369
- {
370
- return TimeSpan . Zero ;
371
- }
372
-
373
- int timeYear = time . Year ;
374
-
375
- OffsetAndRule match = s_cachedData . GetOneYearLocalFromUtc ( timeYear ) ;
376
- TimeSpan baseOffset = match . Offset ;
377
-
378
- if ( match . Rule != null )
379
- {
380
- baseOffset += match . Rule . BaseUtcOffsetDelta ;
381
- if ( match . Rule . HasDaylightSaving )
382
- {
383
- bool isDaylightSavings = GetIsDaylightSavingsFromUtc ( time , timeYear , match . Offset , match . Rule , null , out isAmbiguousLocalDst , Local ) ;
384
- baseOffset += ( isDaylightSavings ? match . Rule . DaylightDelta : TimeSpan . Zero /* FUTURE: rule.StandardDelta */ ) ;
385
- }
386
- }
387
-
388
- return baseOffset ;
389
- }
390
-
391
322
/// <summary>
392
323
/// Converts a REG_TZI_FORMAT struct to a TransitionTime
393
324
/// - When the argument 'readStart' is true the corresponding daylightTransitionTimeStart field is read
394
- /// - When the argument 'readStart' is false the corresponding dayightTransitionTimeEnd field is read
325
+ /// - When the argument 'readStart' is false the corresponding daylightTransitionTimeEnd field is read
395
326
/// </summary>
396
327
private static bool TransitionTimeFromTimeZoneInformation ( in REG_TZI_FORMAT timeZoneInformation , out TransitionTime transitionTime , bool readStartDate )
397
328
{
0 commit comments