Skip to content

Commit

Permalink
fixes Humanizr#1186 replacing 'now' with 'today' for all day or longe…
Browse files Browse the repository at this point in the history
…r time periods
  • Loading branch information
AJacksonCT committed Jun 7, 2023
1 parent 5dfb5ae commit a7e3e99
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 139 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ The default precision is set to .75 but you can pass your desired precision too.
104 seconds => one minute ago/from now
105 seconds => two minutes ago/from now

25 days => a month ago/from now
25 days => a month ago/from today
```

**No dehumanization for dates as `Humanize` is a lossy transformation and the human friendly date is not reversible**
Expand Down
22 changes: 11 additions & 11 deletions src/Humanizer.Tests.Shared/DateHumanizeDefaultStrategyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void HoursFromNow(int hours, string expected)

[Theory]
[InlineData(38, "tomorrow")]
[InlineData(40, "2 days from now")]
[InlineData(40, "2 days from today")]
public void HoursFromNowNotTomorrow(int hours, string expected)
{
//Only test with injected date, as results are dependent on time of day
Expand All @@ -98,9 +98,9 @@ public void DaysAgo(int days, string expected)

[Theory]
[InlineData(1, "tomorrow")]
[InlineData(10, "10 days from now")]
[InlineData(27, "27 days from now")]
[InlineData(32, "one month from now")]
[InlineData(10, "10 days from today")]
[InlineData(27, "27 days from today")]
[InlineData(32, "one month from today")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future);
Expand All @@ -117,10 +117,10 @@ public void MonthsAgo(int months, string expected)
}

[Theory]
[InlineData(1, "one month from now")]
[InlineData(10, "10 months from now")]
[InlineData(11, "11 months from now")]
[InlineData(12, "one year from now")]
[InlineData(1, "one month from today")]
[InlineData(10, "10 months from today")]
[InlineData(11, "11 months from today")]
[InlineData(12, "one year from today")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future);
Expand All @@ -135,8 +135,8 @@ public void YearsAgo(int years, string expected)
}

[Theory]
[InlineData(1, "one year from now")]
[InlineData(2, "2 years from now")]
[InlineData(1, "one year from today")]
[InlineData(2, "2 years from today")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future);
Expand Down Expand Up @@ -164,7 +164,7 @@ public void Nullable_ExpectSame()
}

[Theory]
[InlineData(1, TimeUnit.Year, Tense.Future, "en-US", "one year from now")]
[InlineData(1, TimeUnit.Year, Tense.Future, "en-US", "one year from today")]
[InlineData(40, TimeUnit.Second, Tense.Past, "ru-RU", "40 секунд назад")]
[InlineData(2, TimeUnit.Day, Tense.Past, "sv-SE", "för 2 dagar sedan")]
public void CanSpecifyCultureExplicitly(int unit, TimeUnit timeUnit, Tense tense, string culture, string expected)
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer.Tests.Shared/DateOnlyHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void DefaultStrategy_MonthApart()
var inputTime = new DateOnly(2015, 08, 05);
var baseTime = new DateOnly(2015, 07, 05);

const string expectedResult = "one month from now";
const string expectedResult = "one month from today";
var actualResult = inputTime.Humanize(baseTime);

Assert.Equal(expectedResult, actualResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public void HoursAgo(int hours, string expected)
[InlineData(18, "tomorrow")]
[InlineData(24, "tomorrow")]
[InlineData(41, "tomorrow")]
[InlineData(42, "2 days from now")]
[InlineData(48, "2 days from now")]
[InlineData(60, "2 days from now")]
[InlineData(42, "2 days from today")]
[InlineData(48, "2 days from today")]
[InlineData(60, "2 days from today")]
public void HoursFromNow(int hours, string expected)
{
DateHumanize.Verify(expected, hours, TimeUnit.Hour, Tense.Future, DefaultPrecision);
Expand All @@ -134,13 +134,13 @@ public void DaysAgo(int days, string expected)

[Theory]
[InlineData(1, "tomorrow")]
[InlineData(10, "10 days from now")]
[InlineData(20, "20 days from now")]
[InlineData(22, "22 days from now")]
[InlineData(23, "one month from now")]
[InlineData(31, "one month from now")]
[InlineData(43, "one month from now")]
[InlineData(53, "2 months from now")]
[InlineData(10, "10 days from today")]
[InlineData(20, "20 days from today")]
[InlineData(22, "22 days from today")]
[InlineData(23, "one month from today")]
[InlineData(31, "one month from today")]
[InlineData(43, "one month from today")]
[InlineData(53, "2 months from today")]
public void DaysFromNow(int days, string expected)
{
DateHumanize.Verify(expected, days, TimeUnit.Day, Tense.Future, DefaultPrecision);
Expand All @@ -160,13 +160,13 @@ public void MonthsAgo(int months, string expected)
}

[Theory]
[InlineData(1, "one month from now")]
[InlineData(8, "8 months from now")]
[InlineData(9, "one year from now")]
[InlineData(12, "one year from now")]
[InlineData(19, "one year from now")]
[InlineData(21, "2 years from now")]
[InlineData(24, "2 years from now")]
[InlineData(1, "one month from today")]
[InlineData(8, "8 months from today")]
[InlineData(9, "one year from today")]
[InlineData(12, "one year from today")]
[InlineData(19, "one year from today")]
[InlineData(21, "2 years from today")]
[InlineData(24, "2 years from today")]
public void MonthsFromNow(int months, string expected)
{
DateHumanize.Verify(expected, months, TimeUnit.Month, Tense.Future, DefaultPrecision);
Expand All @@ -181,8 +181,8 @@ public void YearsAgo(int years, string expected)
}

[Theory]
[InlineData(1, "one year from now")]
[InlineData(2, "2 years from now")]
[InlineData(1, "one year from today")]
[InlineData(2, "2 years from today")]
public void YearsFromNow(int years, string expected)
{
DateHumanize.Verify(expected, years, TimeUnit.Year, Tense.Future, DefaultPrecision);
Expand Down
Loading

0 comments on commit a7e3e99

Please sign in to comment.