Skip to content

Commit

Permalink
Added more cases to DateService
Browse files Browse the repository at this point in the history
  • Loading branch information
gumbarros committed Jan 13, 2025
1 parent 0bb70e9 commit af657eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Commons/Localization/MasterDataResources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -4157,6 +4157,12 @@
<data name="{0} months and 1 day ago" xml:space="preserve">
<value>Há {0} meses e 1 dia</value>
</data>
<data name="A month ago" xml:space="preserve">
<value>Há 1 mês</value>
</data>
<data name="A month and 1 day ago" xml:space="preserve">
<value>Há 1 mês e 1 dia</value>
</data>
<data name="{0} months and {1} days ago" xml:space="preserve">
<value>Há {0} meses e {1} dias</value>
</data>
Expand Down
21 changes: 15 additions & 6 deletions src/Commons/Util/DateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,24 @@ public string GetPhrase(DateTime date)
int remainingDays = (int)(timeDifference.TotalDays % 30);
if (remainingDays == 1)
{
return months == 0
? localizer["1 day ago"]
: localizer["{0} months and 1 day ago", months];
if (months == 0)
return localizer["1 day ago"];

if (months == 1)
return localizer["A month and 1 day ago", months];

return localizer["{0} months and 1 day ago", months];
}

return months == 0
? localizer["{0} days ago", remainingDays]
: localizer["{0} months and {1} days ago", months, remainingDays];
if (months == 0)
return localizer["{0} days ago", remainingDays];

if (months == 1 && remainingDays == 0)
return localizer["A month ago"];

return localizer["{0} months and {1} days ago", months, remainingDays];
}

int years = (int)(timeDifference.TotalDays / 365);
return years == 1
? localizer["1 year ago"]
Expand Down

0 comments on commit af657eb

Please sign in to comment.