Author: atsushi
Date: 2007-07-10 03:01:38 -0400 (Tue, 10 Jul 2007)
New Revision: 81688
Modified:
trunk/mcs/class/corlib/System.Globalization/ChangeLog
trunk/mcs/class/corlib/System.Globalization/GregorianCalendar.cs
trunk/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
trunk/mcs/class/corlib/System.Globalization/HijriCalendar.cs
trunk/mcs/class/corlib/System.Globalization/JulianCalendar.cs
trunk/mcs/class/corlib/System.Globalization/KoreanCalendar.cs
trunk/mcs/class/corlib/System.Globalization/ThaiBuddhistCalendar.cs
trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog
Log:
2007-07-10 Atsushi Enomoto <[EMAIL PROTECTED]>
* HijriCalendar.cs ThaiBuddhistCalendar.cs HebrewCalendar.cs
GregorianCalendar.cs KoreanCalendar.cs JulianCalendar.cs :
implemented ToFourDigitYear(), actually base implementation mostly
works as is.
* CalendarTest.cs : enabled ToFourDigitYear() test from 5 years ago.
and added some more ToFourDigitYear() tests.
Modified: trunk/mcs/class/corlib/System.Globalization/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/ChangeLog 2007-07-10
04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/ChangeLog 2007-07-10
07:01:38 UTC (rev 81688)
@@ -1,3 +1,10 @@
+2007-07-10 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * HijriCalendar.cs ThaiBuddhistCalendar.cs HebrewCalendar.cs
+ GregorianCalendar.cs KoreanCalendar.cs JulianCalendar.cs :
+ implemented ToFourDigitYear(), actually base implementation mostly
+ works as is.
+
2007-07-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* CultureInfo.cs : 1.x build fix.
Modified: trunk/mcs/class/corlib/System.Globalization/GregorianCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/GregorianCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/GregorianCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -481,10 +481,9 @@
hour, minute, second, milliseconds);
}
- [MonoTODO ("Not supported")]
public override int ToFourDigitYear(int year)
{
- throw new NotImplementedException();
+ return base.ToFourDigitYear (year);
}
/// <summary>
Modified: trunk/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/HebrewCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -692,11 +692,13 @@
public override int ToFourDigitYear (int year)
{
- M_ArgumentInRange ("year", year, 0, 99);
+ M_ArgumentInRange ("year", year, 0, M_MaxYear - 1);
int baseExtra = this.twoDigitYearMax % 100;
int baseCentury = this.twoDigitYearMax - baseExtra;
+ if (year >= 100)
+ return year;
if (year <= baseExtra)
return baseCentury + year;
else
Modified: trunk/mcs/class/corlib/System.Globalization/HijriCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/HijriCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/HijriCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -936,10 +936,9 @@
hour, minute, second, milliseconds);
}
- [MonoTODO ("Not supported")]
public override int ToFourDigitYear(int year)
{
- throw new NotImplementedException();
+ return base.ToFourDigitYear (year);
}
#if NET_2_0
Modified: trunk/mcs/class/corlib/System.Globalization/JulianCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/JulianCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/JulianCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -488,10 +488,9 @@
hour, minute, second, milliseconds);
}
- [MonoTODO("Not supported")]
public override int ToFourDigitYear(int year)
{
- throw new NotImplementedException();
+ return base.ToFourDigitYear (year);
}
#if NET_2_0
Modified: trunk/mcs/class/corlib/System.Globalization/KoreanCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/KoreanCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/KoreanCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -497,10 +497,9 @@
month, day, hour, minute, second, milliseconds);
}
- [MonoTODO("Not supported")]
public override int ToFourDigitYear(int year)
{
- throw new NotImplementedException();
+ return base.ToFourDigitYear (year);
}
#if NET_2_0
Modified: trunk/mcs/class/corlib/System.Globalization/ThaiBuddhistCalendar.cs
===================================================================
--- trunk/mcs/class/corlib/System.Globalization/ThaiBuddhistCalendar.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/System.Globalization/ThaiBuddhistCalendar.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -498,10 +498,9 @@
hour, minute, second, milliseconds);
}
- [MonoTODO ("Not supported")]
public override int ToFourDigitYear(int year)
{
- throw new NotImplementedException();
+ return base.ToFourDigitYear (year);
}
#if NET_2_0
Modified: trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
===================================================================
--- trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
2007-07-10 04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/Test/System.Globalization/CalendarTest.cs
2007-07-10 07:01:38 UTC (rev 81688)
@@ -687,9 +687,6 @@
}
#endif
- /* UK TODO: breaks with current DateTime implementation.
- * I've a newer one that works, but that requires to much changes.
- * for now.
public void TestToFourDigitYear() {
foreach (Calendar cal in acal) {
bool working = true;
@@ -742,8 +739,53 @@
cal), exception);
}
}
- */
+ [Test]
+ public void TestToFourDigitYear2 ()
+ {
+ GregorianCalendar gc = new GregorianCalendar ();
+ AssertEquals ("#1-1", 2029, gc.ToFourDigitYear (29));
+ AssertEquals ("#1-2", 1930, gc.ToFourDigitYear (30));
+ AssertEquals ("#1-3", 2029, gc.ToFourDigitYear (2029));
+ AssertEquals ("#1-4", 2030, gc.ToFourDigitYear (2030));
+
+ HebrewCalendar hbc = new HebrewCalendar ();
+ AssertEquals ("#2-1", 5790, hbc.ToFourDigitYear (90));
+ AssertEquals ("#2-2", 5691, hbc.ToFourDigitYear (91));
+ AssertEquals ("#2-3", 5790, hbc.ToFourDigitYear (5790));
+ AssertEquals ("#2-4", 5691, hbc.ToFourDigitYear (5691));
+ AssertEquals ("#2-5", 5999, hbc.ToFourDigitYear (5999));
+ // LAMESPEC: .NET fails to throw an exception unlike documented
+ /*
+ try {
+ hbc.ToFourDigitYear (6000);
+ Fail ("#2-6");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ */
+
+ ThaiBuddhistCalendar tc = new ThaiBuddhistCalendar ();
+ AssertEquals ("#3-1", 2572, tc.ToFourDigitYear (72));
+ AssertEquals ("#3-2", 2473, tc.ToFourDigitYear (73));
+ AssertEquals ("#3-3", 2572, tc.ToFourDigitYear (2572));
+ AssertEquals ("#3-4", 2573, tc.ToFourDigitYear (2573));
+ AssertEquals ("#3-5", 9999, tc.ToFourDigitYear (9999));
+ // LAMESPEC: .NET fails to throw an exception unlike documented
+ /*
+ try {
+ tc.ToFourDigitYear (10000);
+ Fail ("#3-6");
+ } catch (ArgumentOutOfRangeException) {
+ }
+ */
+
+ KoreanCalendar kc = new KoreanCalendar ();
+ AssertEquals ("#4-1", 4362, kc.ToFourDigitYear (62));
+ AssertEquals ("#4-2", 4263, kc.ToFourDigitYear (63));
+ AssertEquals ("#4-3", 4362, kc.ToFourDigitYear (4362));
+ AssertEquals ("#4-4", 4363, kc.ToFourDigitYear (4363));
+ }
+
// TODO: more tests :-)
} // class CalendarTest
Modified: trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog 2007-07-10
04:46:47 UTC (rev 81687)
+++ trunk/mcs/class/corlib/Test/System.Globalization/ChangeLog 2007-07-10
07:01:38 UTC (rev 81688)
@@ -1,3 +1,8 @@
+2007-07-10 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * CalendarTest.cs : enabled ToFourDigitYear() test from 5 years ago.
+ and added some more ToFourDigitYear() tests.
+
2007-07-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* CalendarTest.cs : added GetWeekOfYear() test.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches