-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempted to replicate timezone issue
- Loading branch information
1 parent
c927de4
commit c5e137c
Showing
6 changed files
with
112 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace MFiles.VAF.Extensions.Tests | ||
{ | ||
public class LocalTimeZoneInfoMocker : IDisposable | ||
{ | ||
public LocalTimeZoneInfoMocker(string timeZoneId) | ||
: this(TimeZoneInfo.FindSystemTimeZoneById(timeZoneId)) | ||
{ | ||
} | ||
public LocalTimeZoneInfoMocker(TimeZoneInfo mockTimeZoneInfo) | ||
{ | ||
var info = typeof(TimeZoneInfo).GetField("s_cachedData", BindingFlags.NonPublic | BindingFlags.Static); | ||
var cachedData = info.GetValue(null); | ||
var field = cachedData.GetType().GetField("m_localTimeZone", | ||
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Instance); | ||
field.SetValue(cachedData, mockTimeZoneInfo); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
TimeZoneInfo.ClearCachedData(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters