34 lines
991 B
C#
34 lines
991 B
C#
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|
|
|
internal abstract class Age
|
|
{
|
|
|
|
internal static (int, TimeSpan) GetAge(long minuendTicks, long subtrahendTicks)
|
|
{
|
|
TimeSpan result;
|
|
int years = 0;
|
|
DateTime check = new(subtrahendTicks);
|
|
for (int i = 0; i < int.MaxValue; i++)
|
|
{
|
|
check = check.AddYears(1);
|
|
if (check.Ticks > minuendTicks)
|
|
break;
|
|
years += 1;
|
|
}
|
|
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);
|
|
}
|
|
|
|
} |