| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<00000142361ab65d-fe8df60a-f679-4b25-89d4-7d90afeafb82-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/b68ef214e196...8bccb2fb739d
Commit: 23dfdd23d8aab754ce66cfac671c96607619ac32
Author: Alistair Bush <[email protected]> (alistair)
Date: 2013-11-03 08:56:38 GMT
URL: https://github.com/mono/mono/commit/23dfdd23d8aab754ce66cfac671c96607619ac32
Add unit test for NZST
Changed paths:
M mcs/class/corlib/Test/System/TimeZoneTest.cs
Modified: mcs/class/corlib/Test/System/TimeZoneTest.cs
===================================================================
@@ -122,6 +122,32 @@ private void TST (TimeZone t1)
Assert.AreEqual(0L, t1.GetUtcOffset (d5).Ticks, "D14");
}
+ private void NZST(TimeZone t1) {
+ Assert.AreEqual("NZST", t1.StandardName, "E01");
+ Assert.AreEqual("NZDT", t1.DaylightName, "E02");
+
+ DaylightTime d1 = t1.GetDaylightChanges (2013);
+ Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G"), "E03");
+ Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G"), "E04");
+ Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");
+
+ DaylightTime d2 = t1.GetDaylightChanges (2001);
+ Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G"), "E06");
+ Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G"), "E07");
+ Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");
+
+ DateTime d3 = new DateTime(2013,02,15);
+ Assert.AreEqual(true, t1.IsDaylightSavingTime (d3), "E09");
+ DateTime d4 = new DateTime(2013,04,30);
+ Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "E10");
+ DateTime d5 = new DateTime(2013,11,03);
+ Assert.AreEqual(true, t1.IsDaylightSavingTime (d5), "E11");
+
+ Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
+ Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
+ Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");
+ }
+
[Test]
[Culture ("")]
public void TestCtors ()
@@ -141,6 +167,9 @@ public void TestCtors ()
case "GMT":
GMT (t1);
break;
+ case "NZST":
+ NZST (t1);
+ break;
default:
NUnit.Framework.Assert.Ignore ("Your time zone (" + t1.StandardName + ") isn't defined in the test case");
break;
Commit: 883a0e0e7d108afd17ff3bf4be6afaf1c754a1a0
Author: Alistair Bush <[email protected]> (alistair)
Date: 2013-11-03 09:28:36 GMT
URL: https://github.com/mono/mono/commit/883a0e0e7d108afd17ff3bf4be6afaf1c754a1a0
Attempt to implement GetTimeZoneData to support all hemispheres
Changed paths:
M mono/metadata/icall.c
Modified: mono/metadata/icall.c
===================================================================
@@ -5930,10 +5930,12 @@ enum {
struct tm start, tt;
time_t t;
- long int gmtoff;
- int is_daylight = 0, day;
+ long int gmtoff, gmtoff_st, gmtoff_ds;
+ int day, transitioned;
char tzone [64];
+ gmtoff_st = gmtoff_ds = transitioned = 0;
+
MONO_ARCH_SAVE_REGS;
MONO_CHECK_ARG_NULL (data);
@@ -5974,8 +5976,10 @@ enum {
t += 3600*24;
tt = *localtime (&t);
+ long int gmtoff_after = gmt_offset(&tt, t);
+
/* Daylight saving starts or ends here. */
- if (gmt_offset (&tt, t) != gmtoff) {
+ if (gmtoff_after != gmtoff) {
struct tm tt1;
time_t t1;
@@ -5995,36 +5999,37 @@ enum {
strftime (tzone, sizeof (tzone), "%Z", &tt);
/* Write data, if we're already in daylight saving, we're done. */
- if (is_daylight) {
- mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
- return 1;
+ if (tt.tm_isdst) {
+ mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
+ mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
+ if (gmtoff_ds == 0) {
+ gmtoff_st = gmtoff;
+ gmtoff_ds = gmtoff_after;
+ }
+ transitioned++;
} else {
- struct tm end;
time_t te;
+ te = mktime (&tt);
- memset (&end, 0, sizeof (end));
- end.tm_year = year-1900 + 1;
- end.tm_mday = 1;
-
- te = mktime (&end);
-
- mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 1, ((gint64)te + EPOCH_ADJUST) * 10000000L);
- is_daylight = 1;
+ mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
+ if (gmtoff_ds == 0) {
+ gmtoff_st = gmtoff_after;
+ gmtoff_ds = gmtoff;
+ }
+ transitioned++;
}
/* This is only set once when we enter daylight saving. */
- mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
- mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (&tt, t) - gmtoff) * 10000000L);
-
+ if (tt1.tm_isdst) {
+ mono_array_set ((*data), gint64, 2, (gint64)gmtoff_st * 10000000L);
+ mono_array_set ((*data), gint64, 3, (gint64)(gmtoff_ds - gmtoff_st) * 10000000L);
+ }
gmtoff = gmt_offset (&tt, t);
}
}
- if (!is_daylight) {
+ if (transitioned < 2) {
strftime (tzone, sizeof (tzone), "%Z", &tt);
mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
Commit: 813fe8057db7f216042da9f35309bda0e1a6aa04
Author: Alistair Bush <[email protected]> (alistair)
Date: 2013-11-03 09:29:15 GMT
URL: https://github.com/mono/mono/commit/813fe8057db7f216042da9f35309bda0e1a6aa04
Fix compile warning and break from for loop once complete
Changed paths:
M mono/metadata/icall.c
Modified: mono/metadata/icall.c
===================================================================
@@ -5930,7 +5930,7 @@ enum {
struct tm start, tt;
time_t t;
- long int gmtoff, gmtoff_st, gmtoff_ds;
+ long int gmtoff, gmtoff_after, gmtoff_st, gmtoff_ds;
int day, transitioned;
char tzone [64];
@@ -5971,12 +5971,12 @@ enum {
gmtoff = gmt_offset (&start, t);
/* For each day of the year, calculate the tm_gmtoff. */
- for (day = 0; day < 365; day++) {
+ for (day = 0; day < 365 && transitioned < 2; day++) {
t += 3600*24;
tt = *localtime (&t);
- long int gmtoff_after = gmt_offset(&tt, t);
+ gmtoff_after = gmt_offset(&tt, t);
/* Daylight saving starts or ends here. */
if (gmtoff_after != gmtoff) {
Commit: 8bccb2fb739db7173205d44dfda56b32d58fc6e3
Author: Atsushi Eno <[email protected]> (atsushieno)
Date: 2013-11-08 05:02:24 GMT
URL: https://github.com/mono/mono/commit/8bccb2fb739db7173205d44dfda56b32d58fc6e3
Merge pull request #800 from alistair/south_timezone_fix
Southern Hemisphere timezone fix
Changed paths:
M mcs/class/corlib/Test/System/TimeZoneTest.cs
M mono/metadata/icall.c
Modified: mcs/class/corlib/Test/System/TimeZoneTest.cs
===================================================================
@@ -122,6 +122,32 @@ private void TST (TimeZone t1)
Assert.AreEqual(0L, t1.GetUtcOffset (d5).Ticks, "D14");
}
+ private void NZST(TimeZone t1) {
+ Assert.AreEqual("NZST", t1.StandardName, "E01");
+ Assert.AreEqual("NZDT", t1.DaylightName, "E02");
+
+ DaylightTime d1 = t1.GetDaylightChanges (2013);
+ Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G"), "E03");
+ Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G"), "E04");
+ Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");
+
+ DaylightTime d2 = t1.GetDaylightChanges (2001);
+ Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G"), "E06");
+ Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G"), "E07");
+ Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");
+
+ DateTime d3 = new DateTime(2013,02,15);
+ Assert.AreEqual(true, t1.IsDaylightSavingTime (d3), "E09");
+ DateTime d4 = new DateTime(2013,04,30);
+ Assert.AreEqual(false, t1.IsDaylightSavingTime (d4), "E10");
+ DateTime d5 = new DateTime(2013,11,03);
+ Assert.AreEqual(true, t1.IsDaylightSavingTime (d5), "E11");
+
+ Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
+ Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
+ Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");
+ }
+
[Test]
[Culture ("")]
public void TestCtors ()
@@ -141,6 +167,9 @@ public void TestCtors ()
case "GMT":
GMT (t1);
break;
+ case "NZST":
+ NZST (t1);
+ break;
default:
NUnit.Framework.Assert.Ignore ("Your time zone (" + t1.StandardName + ") isn't defined in the test case");
break;
Modified: mono/metadata/icall.c
===================================================================
@@ -5930,10 +5930,12 @@ enum {
struct tm start, tt;
time_t t;
- long int gmtoff;
- int is_daylight = 0, day;
+ long int gmtoff, gmtoff_after, gmtoff_st, gmtoff_ds;
+ int day, transitioned;
char tzone [64];
+ gmtoff_st = gmtoff_ds = transitioned = 0;
+
MONO_ARCH_SAVE_REGS;
MONO_CHECK_ARG_NULL (data);
@@ -5969,13 +5971,15 @@ enum {
gmtoff = gmt_offset (&start, t);
/* For each day of the year, calculate the tm_gmtoff. */
- for (day = 0; day < 365; day++) {
+ for (day = 0; day < 365 && transitioned < 2; day++) {
t += 3600*24;
tt = *localtime (&t);
+ gmtoff_after = gmt_offset(&tt, t);
+
/* Daylight saving starts or ends here. */
- if (gmt_offset (&tt, t) != gmtoff) {
+ if (gmtoff_after != gmtoff) {
struct tm tt1;
time_t t1;
@@ -5995,36 +5999,37 @@ enum {
strftime (tzone, sizeof (tzone), "%Z", &tt);
/* Write data, if we're already in daylight saving, we're done. */
- if (is_daylight) {
- mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
- return 1;
+ if (tt.tm_isdst) {
+ mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
+ mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
+ if (gmtoff_ds == 0) {
+ gmtoff_st = gmtoff;
+ gmtoff_ds = gmtoff_after;
+ }
+ transitioned++;
} else {
- struct tm end;
time_t te;
+ te = mktime (&tt);
- memset (&end, 0, sizeof (end));
- end.tm_year = year-1900 + 1;
- end.tm_mday = 1;
-
- te = mktime (&end);
-
- mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
- mono_array_set ((*data), gint64, 1, ((gint64)te + EPOCH_ADJUST) * 10000000L);
- is_daylight = 1;
+ mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
+ if (gmtoff_ds == 0) {
+ gmtoff_st = gmtoff_after;
+ gmtoff_ds = gmtoff;
+ }
+ transitioned++;
}
/* This is only set once when we enter daylight saving. */
- mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
- mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (&tt, t) - gmtoff) * 10000000L);
-
+ if (tt1.tm_isdst) {
+ mono_array_set ((*data), gint64, 2, (gint64)gmtoff_st * 10000000L);
+ mono_array_set ((*data), gint64, 3, (gint64)(gmtoff_ds - gmtoff_st) * 10000000L);
+ }
gmtoff = gmt_offset (&tt, t);
}
}
- if (!is_daylight) {
+ if (transitioned < 2) {
strftime (tzone, sizeof (tzone), "%Z", &tt);
mono_array_setref ((*names), 0, mono_string_new (domain, tzone));
mono_array_setref ((*names), 1, mono_string_new (domain, tzone));
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches