Moved more to Map library
This commit is contained in:
22
Shared/Models/Stateless/Methods/Age.cs
Normal file
22
Shared/Models/Stateless/Methods/Age.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class Age
|
||||
{
|
||||
|
||||
internal static (int, TimeSpan) GetAge(DateTime minuend, DateTime subtrahend)
|
||||
{
|
||||
TimeSpan result;
|
||||
int years = 0;
|
||||
DateTime check = new(subtrahend.Ticks);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
check = check.AddYears(1);
|
||||
if (check > minuend)
|
||||
break;
|
||||
years += 1;
|
||||
}
|
||||
result = new(minuend.Ticks - check.AddYears(-1).Ticks);
|
||||
return (years, result);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user