diff --git a/src/Humanizer.Tests.Shared/DateHumanizeDefaultStrategyTests.cs b/src/Humanizer.Tests.Shared/DateHumanizeDefaultStrategyTests.cs index 9e850640e..3722c5105 100644 --- a/src/Humanizer.Tests.Shared/DateHumanizeDefaultStrategyTests.cs +++ b/src/Humanizer.Tests.Shared/DateHumanizeDefaultStrategyTests.cs @@ -88,8 +88,8 @@ public void HoursFromNowNotTomorrow(int hours, string expected) [Theory] [InlineData(1, "yesterday")] - [InlineData(10, "10 days ago")] - [InlineData(27, "27 days ago")] + [InlineData(10, "one week ago")] + [InlineData(27, "3 weeks ago")] [InlineData(32, "one month ago")] public void DaysAgo(int days, string expected) { @@ -98,8 +98,8 @@ public void DaysAgo(int days, string expected) [Theory] [InlineData(1, "tomorrow")] - [InlineData(10, "10 days from now")] - [InlineData(27, "27 days from now")] + [InlineData(10, "one week from now")] + [InlineData(27, "3 weeks from now")] [InlineData(32, "one month from now")] public void DaysFromNow(int days, string expected) { diff --git a/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs b/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs index 1b25eea6e..25b525637 100644 --- a/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs +++ b/src/Humanizer/DateTimeHumanizeStrategy/DateTimeHumanizeAlgorithms.cs @@ -150,11 +150,16 @@ public static string DefaultHumanize(DateTime input, DateTime comparisonBase, Cu return formatter.DateHumanize(TimeUnit.Day, tense, days); } - if (ts.TotalDays < 28) + if (ts.TotalDays < 7) { return formatter.DateHumanize(TimeUnit.Day, tense, ts.Days); } + if (ts.TotalDays < 28) + { + return formatter.DateHumanize(TimeUnit.Week, tense, ts.Days / 7); + } + if (ts.TotalDays >= 28 && ts.TotalDays < 30) { if (comparisonBase.Date.AddMonths(tense == Tense.Future ? 1 : -1) == input.Date) @@ -180,4 +185,4 @@ public static string DefaultHumanize(DateTime input, DateTime comparisonBase, Cu return formatter.DateHumanize(TimeUnit.Year, tense, years); } } -} \ No newline at end of file +} diff --git a/src/Humanizer/Properties/Resources.resx b/src/Humanizer/Properties/Resources.resx index 678f0d5cf..9acdd3439 100644 --- a/src/Humanizer/Properties/Resources.resx +++ b/src/Humanizer/Properties/Resources.resx @@ -141,6 +141,12 @@ {0} days ago + + one week ago + + + {0} weeks ago + one month ago @@ -207,6 +213,9 @@ {0} seconds from now + + {0} weeks from now + {0} years from now @@ -228,6 +237,9 @@ one second from now + + one week from now + one year from now