diff options
author | Sebastien Pouliot <sebastien@ximian.com> | 2004-06-11 16:43:42 +0400 |
---|---|---|
committer | Sebastien Pouliot <sebastien@ximian.com> | 2004-06-11 16:43:42 +0400 |
commit | a4b1fa50235c9f213fdaa0e5ad8d26580af4188a (patch) | |
tree | b6ff4f554fc666cdbf288881ec415e98c2382a2c | |
parent | abaf40f801f05f55b61e8084578945e5e16df46e (diff) |
2004-06-11 Sebastien Pouliot <sebastien@ximian.com>
* DateTime.cs: Added a AddRoundedMilliseconds which use the "old Mono"
rounding logic which worked for FromOADate (while the newer didn't).
svn path=/trunk/mcs/; revision=29341
-rw-r--r-- | mcs/class/corlib/System/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/corlib/System/DateTime.cs | 25 |
2 files changed, 24 insertions, 6 deletions
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index e55ab3bba9a..c4c08bc9c81 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,8 @@ +2004-06-11 Sebastien Pouliot <sebastien@ximian.com> + + * DateTime.cs: Added a AddRoundedMilliseconds which use the "old Mono" + rounding logic which worked for FromOADate (while the newer didn't). + 2004-06-11 Martin Baulig <martin@ximian.com> * String.cs (Concat): Implemented the varargs version. diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs index 2c1a193fed7..af483154ee0 100644 --- a/mcs/class/corlib/System/DateTime.cs +++ b/mcs/class/corlib/System/DateTime.cs @@ -431,6 +431,18 @@ namespace System return AddTicks (msticks);
}
+ + // required to match MS implementation for OADate (OLE Automation) + private DateTime AddRoundedMilliseconds (double ms)
+ {
+ if ((ms * TimeSpan.TicksPerMillisecond) > long.MaxValue || + (ms * TimeSpan.TicksPerMillisecond) < long.MinValue) { + throw new ArgumentOutOfRangeException (); + } + long msticks = (long) (ms += ms > 0 ? 0.5 : -0.5) * TimeSpan.TicksPerMillisecond; + + return AddTicks (msticks);
+ }
public DateTime AddMinutes (double minutes)
{
@@ -551,17 +563,18 @@ namespace System if (d < 0.0d) { Double days = Math.Ceiling (d); // integer part is the number of days (negative) - dt = dt.AddDays (days); + dt = dt.AddRoundedMilliseconds (days * 86400000); // but decimals are the number of hours (in days fractions) and positive Double hours = (days - d); - dt = dt.AddDays (hours); + dt = dt.AddRoundedMilliseconds (hours * 86400000); + } + else { + dt = dt.AddRoundedMilliseconds (d * 86400000); } - else - dt = dt.AddDays (d); return dt;
- }
-
+ } + public string[] GetDateTimeFormats()
{
return GetDateTimeFormats (CultureInfo.CurrentCulture);
|