Skip to content

Commit 20d8e01

Browse files
jstedfastp12tic
authored andcommitted
Fix for bug #445855
In this day and age of mobile personal computing devices, we need to periodically check the underlying system timezone because the device may have crossed a timezone boundary.
1 parent 5e5d61b commit 20d8e01

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mcs/class/corlib/System/TimeZone.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public abstract class TimeZone
5656
// Fields
5757
static TimeZone currentTimeZone;
5858

59+
[NonSerialized]
60+
static long timezone_check;
61+
5962
// Constructor
6063
protected TimeZone ()
6164
{
@@ -64,8 +67,13 @@ protected TimeZone ()
6467
// Properties
6568
public static TimeZone CurrentTimeZone {
6669
get {
67-
if (currentTimeZone == null)
68-
currentTimeZone = new CurrentSystemTimeZone (DateTime.GetNow ());
70+
long now = DateTime.GetNow ();
71+
72+
if (currentTimeZone == null || (now - timezone_check) > TimeSpan.TicksPerMinute) {
73+
currentTimeZone = new CurrentSystemTimeZone (now);
74+
timezone_check = now;
75+
}
76+
6977
return currentTimeZone;
7078
}
7179
}

0 commit comments

Comments
 (0)