namespace System
{
[Serializable]
+#if NET_2_0
+ [System.Runtime.InteropServices.ComVisible (true)]
+#endif
public struct TimeSpan : IComparable
+#if NET_2_0
+ , IComparable<TimeSpan>, IEquatable <TimeSpan>
+#endif
{
public static readonly TimeSpan MaxValue = new TimeSpan (long.MaxValue);
public static readonly TimeSpan MinValue = new TimeSpan (long.MinValue);
return Compare (this, (TimeSpan) value);
}
+#if NET_2_0
+ public int CompareTo (TimeSpan value)
+ {
+ return Compare (this, value);
+ }
+
+ public bool Equals (TimeSpan value)
+ {
+ return value._ticks == _ticks;
+ }
+#endif
+
public TimeSpan Duration ()
{
try {
return p.Execute ();
}
+#if NET_2_0
+ public static bool TryParse (string s, out TimeSpan result)
+ {
+ try {
+ result = Parse (s);
+ return true;
+ } catch {
+ result = TimeSpan.Zero;
+ return false;
+ }
+ }
+#endif
+
public TimeSpan Subtract (TimeSpan ts)
{
try {
sb.Append ('.');
}
- sb.Append (IntegerFormatter.FormatDecimal (Math.Abs (Hours), 2, 4));
+ System.Globalization.NumberFormatInfo nfi = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
+ sb.Append (NumberFormatter.FormatDecimal (new NumberFormatter.NumberStore ((int)Math.Abs (Hours)), 2, nfi));
sb.Append (':');
- sb.Append (IntegerFormatter.FormatDecimal (Math.Abs (Minutes), 2, 4));
+ sb.Append (NumberFormatter.FormatDecimal (new NumberFormatter.NumberStore ((int)Math.Abs (Minutes)), 2, nfi));
sb.Append (':');
- sb.Append (IntegerFormatter.FormatDecimal (Math.Abs (Seconds), 2, 4));
+ sb.Append (NumberFormatter.FormatDecimal (new NumberFormatter.NumberStore ((int)Math.Abs (Seconds)), 2, nfi));
int fractional = (int) Math.Abs (_ticks % TicksPerSecond);
if (fractional != 0) {
sb.Append ('.');
- sb.Append (IntegerFormatter.FormatDecimal (Math.Abs (fractional), 7, 4));
+ sb.Append (NumberFormatter.FormatDecimal (new NumberFormatter.NumberStore (fractional), 7, nfi));
}
return sb.ToString ();