Re-Write without checking mapped

This commit is contained in:
2022-09-14 19:00:57 -07:00
parent 73de1070b8
commit ad28ab2d38
70 changed files with 1596 additions and 2342 deletions

View File

@ -3,19 +3,31 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
internal abstract class Age
{
internal static (int, TimeSpan) GetAge(DateTime minuend, DateTime subtrahend)
internal static (int, TimeSpan) GetAge(long minuendTicks, long subtrahendTicks)
{
TimeSpan result;
int years = 0;
DateTime check = new(subtrahend.Ticks);
DateTime check = new(subtrahendTicks);
for (int i = 0; i < int.MaxValue; i++)
{
check = check.AddYears(1);
if (check > minuend)
if (check.Ticks > minuendTicks)
break;
years += 1;
}
result = new(minuend.Ticks - check.AddYears(-1).Ticks);
result = new(minuendTicks - check.AddYears(-1).Ticks);
return (years, result);
}
internal static (int, TimeSpan) GetAge(long minuendTicks, DateTime subtrahend)
{
(int years, TimeSpan result) = GetAge(minuendTicks, subtrahend.Ticks);
return (years, result);
}
internal static (int, TimeSpan) GetAge(DateTime minuend, DateTime subtrahend)
{
(int years, TimeSpan result) = GetAge(minuend.Ticks, subtrahend.Ticks);
return (years, result);
}