diff --git a/src/Umbraco.Core/DateTimeExtensions.cs b/src/Umbraco.Core/DateTimeExtensions.cs
index 6e2676ac72..8332fb9356 100644
--- a/src/Umbraco.Core/DateTimeExtensions.cs
+++ b/src/Umbraco.Core/DateTimeExtensions.cs
@@ -21,9 +21,9 @@ namespace Umbraco.Core
public static DateTime TruncateTo(this DateTime dt, DateTruncate truncateTo)
{
if (truncateTo == DateTruncate.Year)
- return new DateTime(dt.Year, 0, 0);
+ return new DateTime(dt.Year, 1, 1);
if (truncateTo == DateTruncate.Month)
- return new DateTime(dt.Year, dt.Month, 0);
+ return new DateTime(dt.Year, dt.Month, 1);
if (truncateTo == DateTruncate.Day)
return new DateTime(dt.Year, dt.Month, dt.Day);
if (truncateTo == DateTruncate.Hour)
@@ -41,43 +41,43 @@ namespace Umbraco.Core
Hour,
Minute,
Second
- }
-
+ }
+
///
- /// Calculates the number of minutes from a date time, on a rolling daily basis (so if
+ /// Calculates the number of minutes from a date time, on a rolling daily basis (so if
/// date time is before the time, calculate onto next day)
///
/// Date to start from
/// Time to compare against (in Hmm form, e.g. 330, 2200)
- ///
- public static int PeriodicMinutesFrom(this DateTime fromDateTime, string scheduledTime)
- {
- // Ensure time provided is 4 digits long
- if (scheduledTime.Length == 3)
- {
- scheduledTime = "0" + scheduledTime;
- }
-
- var scheduledHour = int.Parse(scheduledTime.Substring(0, 2));
- var scheduledMinute = int.Parse(scheduledTime.Substring(2));
-
- DateTime scheduledDateTime;
- if (IsScheduledInRemainingDay(fromDateTime, scheduledHour, scheduledMinute))
- {
- scheduledDateTime = new DateTime(fromDateTime.Year, fromDateTime.Month, fromDateTime.Day, scheduledHour, scheduledMinute, 0);
- }
- else
- {
- var nextDay = fromDateTime.AddDays(1);
- scheduledDateTime = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, scheduledHour, scheduledMinute, 0);
- }
-
- return (int)(scheduledDateTime - fromDateTime).TotalMinutes;
- }
-
- private static bool IsScheduledInRemainingDay(DateTime fromDateTime, int scheduledHour, int scheduledMinute)
- {
- return scheduledHour > fromDateTime.Hour || (scheduledHour == fromDateTime.Hour && scheduledMinute >= fromDateTime.Minute);
+ ///
+ public static int PeriodicMinutesFrom(this DateTime fromDateTime, string scheduledTime)
+ {
+ // Ensure time provided is 4 digits long
+ if (scheduledTime.Length == 3)
+ {
+ scheduledTime = "0" + scheduledTime;
+ }
+
+ var scheduledHour = int.Parse(scheduledTime.Substring(0, 2));
+ var scheduledMinute = int.Parse(scheduledTime.Substring(2));
+
+ DateTime scheduledDateTime;
+ if (IsScheduledInRemainingDay(fromDateTime, scheduledHour, scheduledMinute))
+ {
+ scheduledDateTime = new DateTime(fromDateTime.Year, fromDateTime.Month, fromDateTime.Day, scheduledHour, scheduledMinute, 0);
+ }
+ else
+ {
+ var nextDay = fromDateTime.AddDays(1);
+ scheduledDateTime = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, scheduledHour, scheduledMinute, 0);
+ }
+
+ return (int)(scheduledDateTime - fromDateTime).TotalMinutes;
+ }
+
+ private static bool IsScheduledInRemainingDay(DateTime fromDateTime, int scheduledHour, int scheduledMinute)
+ {
+ return scheduledHour > fromDateTime.Hour || (scheduledHour == fromDateTime.Hour && scheduledMinute >= fromDateTime.Minute);
}
}
}