using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
+using System.Runtime.Serialization;
namespace System
{
///
[Serializable]
[StructLayout (LayoutKind.Auto)]
- public struct DateTime : IFormattable, IConvertible, IComparable
-#if NET_2_0
- , IComparable<DateTime>, IEquatable <DateTime>
-#endif
+ public struct DateTime : IFormattable, IConvertible, IComparable, ISerializable, IComparable<DateTime>, IEquatable <DateTime>
{
+#if MONOTOUCH
+ static DateTime () {
+ if (MonoTouchAOTHelper.FalseFlag) {
+ var comparer = new System.Collections.Generic.GenericComparer <DateTime> ();
+ var eqcomparer = new System.Collections.Generic.GenericEqualityComparer <DateTime> ();
+ }
+ }
+#endif
private TimeSpan ticks;
-#if NET_2_0
DateTimeKind kind;
-#endif
private const int dp400 = 146097;
private const int dp100 = 36524;
private static readonly string[] ParseTimeFormats = new string [] {
"H:m:s.fffffffzzz",
"H:m:s.fffffff",
+ "H:m:s tt zzz",
"H:m:szzz",
"H:m:s",
"H:mzzz",
"M/yyyy/dT",
"yyyy'\u5E74'M'\u6708'd'\u65E5",
-#if NET_2_0
+
"yyyy/d/MMMM",
"yyyy/MMM/d",
-#else
- "yyyy/MMMM/d",
- "yyyy/d/MMM",
-#endif
"d/MMMM/yyyy",
"MMM/d/yyyy",
"d/yyyy/MMMM",
};
private static readonly string[] DayMonthShortFormats = new string [] {
"d/MMMM",
-#if NET_2_0
"MMM/yy",
-#else // In .Net 1.0 Feb 03 is always Feb 3rd (and not Feb 2003)
- "MMM/d",
-#endif
"yyyy/MMMM",
};
ticks, MinValue.Ticks, MaxValue.Ticks);
throw new ArgumentOutOfRangeException ("ticks", msg);
}
-#if NET_2_0
kind = DateTimeKind.Unspecified;
-#endif
}
public DateTime (int year, int month, int day)
ticks = new TimeSpan (AbsoluteDays(year,month,day), hour, minute, second, millisecond);
-#if NET_2_0
kind = DateTimeKind.Unspecified;
-#endif
}
public DateTime (int year, int month, int day, Calendar calendar)
if (calendar == null)
throw new ArgumentNullException ("calendar");
ticks = calendar.ToDateTime (year, month, day, hour, minute, second, millisecond).ticks;
-#if NET_2_0
kind = DateTimeKind.Unspecified;
-#endif
}
internal DateTime (bool check, TimeSpan value)
ticks = value;
-#if NET_2_0
kind = DateTimeKind.Unspecified;
-#endif
}
-#if NET_2_0
public DateTime (long ticks, DateTimeKind kind) : this (ticks)
{
CheckDateTimeKind (kind);
{
CheckDateTimeKind (kind);
this.kind = kind;
- }
-#endif
+ }
+ //
+ // Not visible, but can be invoked during deserialization
+ //
+ DateTime (SerializationInfo info, StreamingContext context)
+ {
+ if (info.HasKey ("dateData")){
+ long dateData = info.GetInt64 ("dateData");
+ kind = (DateTimeKind) (dateData >> 62);
+ ticks = new TimeSpan (dateData & 0x3fffffffffffffff);
+ } else if (info.HasKey ("ticks")){
+ ticks = new TimeSpan (info.GetInt64 ("ticks"));
+ kind = DateTimeKind.Unspecified;
+ } else {
+ kind = DateTimeKind.Unspecified;
+ ticks = new TimeSpan (0);
+ }
+ }
+
+
/* Properties */
public DateTime Date
get
{
DateTime ret = new DateTime (Year, Month, Day);
-#if NET_2_0
ret.kind = kind;
-#endif
return ret;
}
}
// This is boxed, so we avoid locking.
DateTime ret = dt + (TimeSpan) to_local_time_span_object;
-#if NET_2_0
ret.kind = DateTimeKind.Local;
-#endif
return ret;
}
}
get {
DateTime now = Now;
DateTime today = new DateTime (now.Year, now.Month, now.Day);
-#if NET_2_0
today.kind = now.kind;
-#endif
return today;
}
}
public static DateTime UtcNow
{
get {
-#if NET_2_0
return new DateTime (GetNow (), DateTimeKind.Utc);
-#else
- return new DateTime (GetNow ());
-#endif
}
}
}
}
-#if NET_2_0
public DateTimeKind Kind {
get {
return kind;
}
}
-#endif
/* methods */
public DateTime Add (TimeSpan value)
{
DateTime ret = AddTicks (value.Ticks);
-#if NET_2_0
ret.kind = kind;
-#endif
return ret;
}
throw new ArgumentOutOfRangeException();
}
DateTime ret = new DateTime (value + ticks.Ticks);
-#if NET_2_0
ret.kind = kind;
-#endif
return ret;
}
(value * TimeSpan.TicksPerMillisecond) < long.MinValue) {
throw new ArgumentOutOfRangeException();
}
- long msticks = (long) (value * TimeSpan.TicksPerMillisecond);
+ long msticks = (long) Math.Round (value * TimeSpan.TicksPerMillisecond);
return AddTicks (msticks);
}
day = maxday;
temp = new DateTime (year, month, day);
-#if NET_2_0
temp.kind = kind;
-#endif
return temp.Add (this.TimeOfDay);
}
return Compare (this, (DateTime) value);
}
-#if NET_2_0
public bool IsDaylightSavingTime ()
{
if (kind == DateTimeKind.Utc)
return new DateTime (value.Ticks, kind);
}
-#else
-
- internal long ToBinary ()
- {
- return Ticks;
- }
-
- internal static DateTime FromBinary (long dateData)
- {
- return new DateTime (dateData & 0x3fffffffffffffff);
- }
-#endif
-
public static int DaysInMonth (int year, int month)
{
int[] days ;
return new DateTime (w32file_epoch + fileTime).ToLocalTime ();
}
-#if NET_1_1
public static DateTime FromFileTimeUtc (long fileTime)
{
if (fileTime < 0)
return new DateTime (w32file_epoch + fileTime);
}
-#endif
public static DateTime FromOADate (double d)
{
return results;
}
-#if NET_2_0
private void CheckDateTimeKind (DateTimeKind kind) {
if ((kind != DateTimeKind.Unspecified) && (kind != DateTimeKind.Utc) && (kind != DateTimeKind.Local))
throw new ArgumentException ("Invalid DateTimeKind value.", "kind");
}
-#endif
public override int GetHashCode ()
{
public static DateTime Parse (string s, IFormatProvider provider, DateTimeStyles styles)
{
-
- const string formatExceptionMessage = "String was not recognized as a valid DateTime.";
-#if !NET_2_0
- const string argumentYearRangeExceptionMessage = "Valid values are between 1 and 9999, inclusive.";
-#endif
-
if (s == null)
throw new ArgumentNullException ("s");
+
+ DateTime res;
+ DateTimeOffset dto;
+ Exception exception = null;
+ if (!CoreParse (s, provider, styles, out res, out dto, true, ref exception))
+ throw exception;
+
+ return res;
+ }
+
+ const string formatExceptionMessage = "String was not recognized as a valid DateTime.";
+
+ internal static bool CoreParse (string s, IFormatProvider provider, DateTimeStyles styles,
+ out DateTime result, out DateTimeOffset dto, bool setExceptionOnError, ref Exception exception)
+ {
+ dto = new DateTimeOffset (0, TimeSpan.Zero);
+ if (s == null || s.Length == 0) {
+ if (setExceptionOnError)
+ exception = new FormatException (formatExceptionMessage);
+ result = MinValue;
+ return false;
+ }
+
if (provider == null)
provider = CultureInfo.CurrentCulture;
DateTimeFormatInfo dfi = DateTimeFormatInfo.GetInstance (provider);
- bool longYear = false;
- DateTime result;
// Try first all the combinations of ParseAllDateFormats & ParseTimeFormats
- string[] allDateFormats = YearMonthDayFormats (dfi);
+ string[] allDateFormats = YearMonthDayFormats (dfi, setExceptionOnError, ref exception);
+ if (allDateFormats == null){
+ result = MinValue;
+ return false;
+ }
+
+ bool longYear = false;
for (int i = 0; i < allDateFormats.Length; i++) {
string firstPart = allDateFormats [i];
bool incompleteFormat = false;
- if (_DoParse (s, firstPart, "", false, out result, dfi, styles, true, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, firstPart, "", false, out result, out dto, dfi, styles, true, ref incompleteFormat, ref longYear))
+ return true;
+
if (!incompleteFormat)
continue;
for (int j = 0; j < ParseTimeFormats.Length; j++) {
- if (_DoParse (s, firstPart, ParseTimeFormats [j], false, out result, dfi, styles, true, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, firstPart, ParseTimeFormats [j], false, out result, out dto, dfi, styles, true, ref incompleteFormat, ref longYear))
+ return true;
}
}
- string[] monthDayFormats = IsDayBeforeMonth (dfi) ? DayMonthShortFormats : MonthDayShortFormats;
+
+ //
+ // Month day formats
+ //
+ int dayIndex = dfi.MonthDayPattern.IndexOf('d');
+ int monthIndex = dfi.MonthDayPattern.IndexOf('M');
+ if (dayIndex == -1 || monthIndex == -1){
+ result = MinValue;
+ if (setExceptionOnError)
+ exception = new FormatException (Locale.GetText("Order of month and date is not defined by {0}", dfi.MonthDayPattern));
+ return false;
+ }
+ bool is_day_before_month = dayIndex < monthIndex;
+ string[] monthDayFormats = is_day_before_month ? DayMonthShortFormats : MonthDayShortFormats;
for (int i = 0; i < monthDayFormats.Length; i++) {
bool incompleteFormat = false;
- if (_DoParse (s, monthDayFormats[i], "", false, out result, dfi, styles, true, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, monthDayFormats[i], "", false, out result, out dto, dfi, styles, true, ref incompleteFormat, ref longYear))
+ return true;
}
+
for (int j = 0; j < ParseTimeFormats.Length; j++) {
string firstPart = ParseTimeFormats [j];
bool incompleteFormat = false;
- if (_DoParse (s, firstPart, "", false, out result, dfi, styles, false, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, firstPart, "", false, out result, out dto, dfi, styles, false, ref incompleteFormat, ref longYear))
+ return true;
if (!incompleteFormat)
continue;
for (int i = 0; i < monthDayFormats.Length; i++) {
- if (_DoParse (s, firstPart, monthDayFormats [i], false, out result, dfi, styles, false, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, firstPart, monthDayFormats [i], false, out result, out dto, dfi, styles, false, ref incompleteFormat, ref longYear))
+ return true;
}
for (int i = 0; i < allDateFormats.Length; i++) {
string dateFormat = allDateFormats [i];
if (dateFormat[dateFormat.Length - 1] == 'T')
continue; // T formats must be before the time part
- if (_DoParse (s, firstPart, dateFormat, false, out result, dfi, styles, false, ref incompleteFormat, ref longYear))
- return result;
+ if (_DoParse (s, firstPart, dateFormat, false, out result, out dto, dfi, styles, false, ref incompleteFormat, ref longYear))
+ return true;
}
}
// Try as a last resort all the patterns
- if (ParseExact (s, dfi.GetAllDateTimePatternsInternal (), dfi, styles, out result, false, ref longYear))
- return result;
-
-#if NET_2_0
- // .NET does not throw an ArgumentOutOfRangeException, but .NET 1.1 does.
- throw new FormatException (formatExceptionMessage);
-#else
- if (longYear) {
- throw new ArgumentOutOfRangeException ("year",
- argumentYearRangeExceptionMessage);
- }
+ if (ParseExact (s, dfi.GetAllDateTimePatternsInternal (), dfi, styles, out result, false, ref longYear, setExceptionOnError, ref exception))
+ return true;
- throw new FormatException (formatExceptionMessage);
-#endif
+ if (!setExceptionOnError)
+ return false;
+
+ // .NET 2.x does not throw an ArgumentOutOfRangeException, but .NET 1.1 does.
+ exception = new FormatException (formatExceptionMessage);
+ return false;
}
public static DateTime ParseExact (string s, string format, IFormatProvider provider)
return ParseExact (s, format, provider, DateTimeStyles.None);
}
- private static bool IsDayBeforeMonth (DateTimeFormatInfo dfi)
- {
- int dayIndex = dfi.MonthDayPattern.IndexOf('d');
- int monthIndex = dfi.MonthDayPattern.IndexOf('M');
- if (dayIndex == -1 || monthIndex == -1)
- throw new FormatException (Locale.GetText("Order of month and date is not defined by {0}", dfi.MonthDayPattern));
-
- return dayIndex < monthIndex;
- }
-
- private static string[] YearMonthDayFormats (DateTimeFormatInfo dfi)
+ private static string[] YearMonthDayFormats (DateTimeFormatInfo dfi, bool setExceptionOnError, ref Exception exc)
{
int dayIndex = dfi.ShortDatePattern.IndexOf('d');
int monthIndex = dfi.ShortDatePattern.IndexOf('M');
int yearIndex = dfi.ShortDatePattern.IndexOf('y');
- if (dayIndex == -1 || monthIndex == -1 || yearIndex == -1)
- throw new FormatException (Locale.GetText("Order of year, month and date is not defined by {0}", dfi.ShortDatePattern));
+ if (dayIndex == -1 || monthIndex == -1 || yearIndex == -1){
+ if (setExceptionOnError)
+ exc = new FormatException (Locale.GetText("Order of year, month and date is not defined by {0}", dfi.ShortDatePattern));
+ return null;
+ }
if (yearIndex < monthIndex)
if (monthIndex < dayIndex)
return ParseYearMonthDayFormats;
else if (yearIndex < dayIndex)
return ParseYearDayMonthFormats;
- else
+ else {
// The year cannot be between the date and the month
- throw new FormatException (Locale.GetText("Order of date, year and month defined by {0} is not supported", dfi.ShortDatePattern));
+ if (setExceptionOnError)
+ exc = new FormatException (Locale.GetText("Order of date, year and month defined by {0} is not supported", dfi.ShortDatePattern));
+ return null;
+ }
else if (dayIndex < monthIndex)
return ParseDayMonthYearFormats;
else if (dayIndex < yearIndex)
return ParseMonthDayYearFormats;
- else
+ else {
// The year cannot be between the month and the date
- throw new FormatException (Locale.GetText("Order of month, year and date defined by {0} is not supported", dfi.ShortDatePattern));
+ if (setExceptionOnError)
+ exc = new FormatException (Locale.GetText("Order of month, year and date defined by {0} is not supported", dfi.ShortDatePattern));
+ return null;
+ }
}
private static int _ParseNumber (string s, int valuePos,
string secondPart,
bool exact,
out DateTime result,
+ out DateTimeOffset dto,
DateTimeFormatInfo dfi,
DateTimeStyles style,
bool firstPartIsDate,
bool useutc = false;
bool use_invariant = false;
bool sloppy_parsing = false;
-#if !NET_2_0
- bool afterTimePart = firstPartIsDate && secondPart == "";
-#endif
+ dto = new DateTimeOffset (0, TimeSpan.Zero);
bool flexibleTwoPartsParsing = !exact && secondPart != null;
incompleteFormat = false;
int valuePos = 0;
if (format == null)
return false;
+ if (s == null)
+ return false;
+
if ((style & DateTimeStyles.AllowLeadingWhite) != 0) {
format = format.TrimStart (null);
if (flexibleTwoPartsParsing && pos + num == 0)
{
bool isLetter = IsLetter(s, valuePos);
-#if NET_2_0
if (isLetter) {
-#else
- if (afterTimePart && isLetter) {
-#endif
if (s [valuePos] == 'Z')
num_parsed = 1;
else
chars = format;
len = chars.Length;
isFirstPart = false;
-#if !NET_2_0
- if (!firstPartIsDate || format == "")
- afterTimePart = true;
-#endif
continue;
}
break;
return false;
break;
-#if NET_2_0
case 'F':
leading_zeros = false;
goto case 'f';
-#endif
case 'f':
if (num > 6 || fractionalSeconds != -1)
return false;
else if (num == 1)
tzoffset = _ParseNumber (s, valuePos, 1, 2, true, sloppy_parsing, out num_parsed);
else {
- tzoffset = _ParseNumber (s, valuePos, 1, 2, true, sloppy_parsing, out num_parsed);
+ tzoffset = _ParseNumber (s, valuePos, 1, 2, true, /*sloppy_parsing*/true, out num_parsed);
valuePos += num_parsed;
if (num_parsed < 0)
return false;
num_parsed = 0;
}
break;
-#if NET_2_0
case 'K':
if (s [valuePos] == 'Z') {
valuePos++;
return false;
}
break;
-#endif
+
// LAMESPEC: This should be part of UTCpattern
// string and thus should not be considered here.
//
switch (chars [pos]) {
case 'm':
case 's':
-#if NET_2_0
case 'F':
-#endif
case 'f':
case 'z':
if (s.Length > valuePos && s [valuePos] == 'Z' &&
num = 0;
}
-#if NET_2_0
+ if (pos + 1 < len && chars [pos] == '.' && chars [pos + 1] == 'F') {
+ pos++;
+ while (pos < len && chars [pos] == 'F') // '.FFF....' can be mapped to nothing. See bug #444103
+ pos++;
+ }
while (pos < len && chars [pos] == 'K') // 'K' can be mapped to nothing
pos++;
-#endif
+
if (pos < len)
return false;
if (dayofweek != -1 && dayofweek != (int) result.DayOfWeek)
return false;
- TimeSpan utcoffset;
-
- bool adjustToUniversal = (style & DateTimeStyles.AdjustToUniversal) != 0;
-
- if (tzsign != -1) {
+ if (tzsign == -1) {
+ if (result != DateTime.MinValue) {
+ try {
+ dto = new DateTimeOffset (result);
+ } catch { } // We handle this error in DateTimeOffset.Parse
+ }
+ } else {
if (tzoffmin == -1)
tzoffmin = 0;
if (tzoffset == -1)
tzoffset = 0;
- if (tzsign == 1)
+ if (tzsign == 1) {
tzoffset = -tzoffset;
-
- utcoffset = new TimeSpan (tzoffset, tzoffmin, 0);
- long newticks = (result.ticks - utcoffset).Ticks;
+ tzoffmin = -tzoffmin;
+ }
+ try {
+ dto = new DateTimeOffset (result, new TimeSpan (tzoffset, tzoffmin, 0));
+ } catch {} // We handle this error in DateTimeOffset.Parse
+ }
+ bool adjustToUniversal = (style & DateTimeStyles.AdjustToUniversal) != 0;
+
+ if (tzsign != -1) {
+ long newticks = (result.ticks - dto.Offset).Ticks;
if (newticks < 0)
newticks += TimeSpan.TicksPerDay;
result = new DateTime (false, new TimeSpan (newticks));
-#if NET_2_0
result.kind = DateTimeKind.Utc;
if ((style & DateTimeStyles.RoundtripKind) != 0)
result = result.ToLocalTime ();
-#endif
}
-#if NET_2_0
else if (useutc || ((style & DateTimeStyles.AssumeUniversal) != 0))
result.kind = DateTimeKind.Utc;
else if ((style & DateTimeStyles.AssumeLocal) != 0)
else if (adjustToLocal)
result = result.ToLocalTime ();
}
-#else
- if (!adjustToUniversal && (useutc || tzsign != -1))
- result = result.ToLocalTime ();
-#endif
return true;
}
DateTimeStyles style)
{
DateTimeFormatInfo dfi = DateTimeFormatInfo.GetInstance (provider);
-#if NET_2_0
CheckStyle (style);
-#endif
if (s == null)
throw new ArgumentNullException ("s");
if (formats == null)
DateTime result;
bool longYear = false;
- if (!ParseExact (s, formats, dfi, style, out result, true, ref longYear))
- throw new FormatException ();
+ Exception e = null;
+ if (!ParseExact (s, formats, dfi, style, out result, true, ref longYear, true, ref e))
+ throw e;
return result;
}
-#if NET_2_0
private static void CheckStyle (DateTimeStyles style)
{
if ( (style & DateTimeStyles.RoundtripKind) != 0)
public static bool TryParse (string s, out DateTime result)
{
- try {
- result = Parse (s);
- } catch {
- result = MinValue;
- return false;
+ if (s != null){
+ try {
+ Exception exception = null;
+ DateTimeOffset dto;
+
+ return CoreParse (s, null, DateTimeStyles.AllowWhiteSpaces, out result, out dto, false, ref exception);
+ } catch { }
}
- return true;
+ result = MinValue;
+ return false;
}
public static bool TryParse (string s, IFormatProvider provider, DateTimeStyles styles, out DateTime result)
{
- try {
- result = Parse (s, provider, styles);
- } catch {
- result = MinValue;
- return false;
- }
- return true;
+ if (s != null){
+ try {
+ Exception exception = null;
+ DateTimeOffset dto;
+
+ return CoreParse (s, provider, styles, out result, out dto, false, ref exception);
+ } catch {}
+ }
+ result = MinValue;
+ return false;
}
public static bool TryParseExact (string s, string format,
out DateTime result)
{
string[] formats;
-
formats = new string [1];
formats[0] = format;
DateTimeStyles style,
out DateTime result)
{
- DateTimeFormatInfo dfi = DateTimeFormatInfo.GetInstance (provider);
+ try {
+ DateTimeFormatInfo dfi = DateTimeFormatInfo.GetInstance (provider);
- bool longYear = false;
- return ParseExact (s, formats, dfi, style, out result, true, ref longYear);
+ bool longYear = false;
+ Exception e = null;
+ return ParseExact (s, formats, dfi, style, out result, true, ref longYear, false, ref e);
+ } catch {
+ result = MinValue;
+ return false;
+ }
}
-#endif
private static bool ParseExact (string s, string [] formats,
- DateTimeFormatInfo dfi, DateTimeStyles style, out DateTime ret,
- bool exact, ref bool longYear)
+ DateTimeFormatInfo dfi, DateTimeStyles style, out DateTime ret,
+ bool exact, ref bool longYear,
+ bool setExceptionOnError, ref Exception exception)
{
int i;
bool incompleteFormat = false;
DateTime result;
string format = formats[i];
if (format == null || format == String.Empty)
- throw new FormatException ("Invalid Format String");
+ break;
- if (_DoParse (s, formats[i], null, exact, out result, dfi, style, false, ref incompleteFormat, ref longYear)) {
+ DateTimeOffset dto;
+ if (_DoParse (s, formats[i], null, exact, out result, out dto, dfi, style, false, ref incompleteFormat, ref longYear)) {
ret = result;
return true;
}
}
+
+ if (setExceptionOnError)
+ exception = new FormatException ("Invalid format string");
ret = DateTime.MinValue;
return false;
}
newticks = (new TimeSpan (ticks.Ticks)) - value;
DateTime ret = new DateTime (true,newticks);
-#if NET_2_0
ret.kind = kind;
-#endif
return ret;
}
return(universalTime.Ticks - w32file_epoch);
}
-#if NET_1_1
public long ToFileTimeUtc()
{
if (Ticks < w32file_epoch) {
return (Ticks - w32file_epoch);
}
-#endif
public string ToLongDateString()
{
public static DateTime operator +(DateTime d, TimeSpan t)
{
DateTime ret = new DateTime (true, d.ticks + t);
-#if NET_2_0
ret.kind = d.kind;
-#endif
return ret;
}
public static DateTime operator -(DateTime d,TimeSpan t)
{
DateTime ret = new DateTime (true, d.ticks - t);
-#if NET_2_0
ret.kind = d.kind;
-#endif
return ret;
}
throw new InvalidCastException();
}
- object IConvertible.ToType (Type conversionType, IFormatProvider provider)
+ object IConvertible.ToType (Type targetType, IFormatProvider provider)
{
- if (conversionType == null)
- throw new ArgumentNullException ("conversionType");
+ if (targetType == null)
+ throw new ArgumentNullException ("targetType");
- if (conversionType == typeof (DateTime))
+ if (targetType == typeof (DateTime))
return this;
- else if (conversionType == typeof (String))
+ else if (targetType == typeof (String))
return this.ToString (provider);
- else if (conversionType == typeof (Object))
+ else if (targetType == typeof (Object))
return this;
else
throw new InvalidCastException();
{
throw new InvalidCastException();
}
-
+
UInt32 IConvertible.ToUInt32(IFormatProvider provider)
{
throw new InvalidCastException();
{
throw new InvalidCastException();
}
+
+ void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
+ {
+ long t = ticks.Ticks;
+ info.AddValue ("ticks", t);
+
+ // This is the new .NET format, encodes the kind on the top bits
+ info.AddValue ("dateData", t | (((uint)kind) << 62));
+ }
+
}
}