Skip to content

Commit

Permalink
Revert Add to int argument
Browse files Browse the repository at this point in the history
Cast at call-site to prevent performance degradation.
  • Loading branch information
IDisposable committed Jun 18, 2024
1 parent cb7004a commit 8683434
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ internal static void CheckAddResult(long ticks, DateTime minValue, DateTime maxV
}
}

internal DateTime Add(DateTime time, double value, long scale)
internal DateTime Add(DateTime time, double value, int scale)
{
// From ECMA CLI spec, Partition III, section 3.27:
//
Expand Down Expand Up @@ -169,7 +169,7 @@ public virtual DateTime AddMilliseconds(DateTime time, double milliseconds)
/// </summary>
public virtual DateTime AddDays(DateTime time, int days)
{
return Add(time, days, TimeSpan.MillisecondsPerDay);
return Add(time, days, (int)TimeSpan.MillisecondsPerDay);
}

/// <summary>
Expand All @@ -181,7 +181,7 @@ public virtual DateTime AddDays(DateTime time, int days)
/// </summary>
public virtual DateTime AddHours(DateTime time, int hours)
{
return Add(time, hours, TimeSpan.MillisecondsPerHour);
return Add(time, hours, (int)TimeSpan.MillisecondsPerHour);
}

/// <summary>
Expand All @@ -193,7 +193,7 @@ public virtual DateTime AddHours(DateTime time, int hours)
/// </summary>
public virtual DateTime AddMinutes(DateTime time, int minutes)
{
return Add(time, minutes, TimeSpan.MillisecondsPerMinute);
return Add(time, minutes, (int)TimeSpan.MillisecondsPerMinute);
}

/// <summary>
Expand Down Expand Up @@ -225,7 +225,7 @@ public virtual DateTime AddMinutes(DateTime time, int minutes)
/// </summary>
public virtual DateTime AddSeconds(DateTime time, int seconds)
{
return Add(time, seconds, TimeSpan.MillisecondsPerSecond);
return Add(time, seconds, (int)TimeSpan.MillisecondsPerSecond);
}

// Returns the DateTime resulting from adding a number of
Expand Down

0 comments on commit 8683434

Please sign in to comment.