AgeCalculator 1.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package AgeCalculator --version 1.1.2
NuGet\Install-Package AgeCalculator -Version 1.1.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AgeCalculator" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AgeCalculator --version 1.1.2
#r "nuget: AgeCalculator, 1.1.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AgeCalculator as a Cake Addin
#addin nuget:?package=AgeCalculator&version=1.1.2

// Install AgeCalculator as a Cake Tool
#tool nuget:?package=AgeCalculator&version=1.1.2

Age Calculator

GitHub GitHub issues

AgeCalculator is an age calculation library that can be used to calculate the age between two dates and output years, months, days and time components.

Dependencies

.NET 5+

How To Use (C# Code)

/* There are three ways to calculate the age between two dates */
using AgeCalculator;
using AgeCalculator.Extensions;

public void PrintMyAge()
{
    // Date of birth or from date.
    var dob = DateTime.Parse("10/03/2015");
    
    // #1. Using the Age class constructor.
    var age = new Age(dob, DateTime.Today); // as of 09/19/2021
    Console.WriteLine($"Age: {age.Years} years, {age.Months} months, {age.Days} days, {age.Time}");
    
    // #2. Using DateTime extension.
    age = dob.CalculateAge(DateTime.Today); // as of 09/19/2021
    Console.WriteLine($"Age: {age.Years} years, {age.Months} months, {age.Days} days, {age.Time}");
    
    // #3. Using the Age type's static function.
    age = Age.Calculate(dob, DateTime.Today); // as of 09/19/2021
    Console.WriteLine($"Age: {age.Years} years, {age.Months} months, {age.Days} days, {age.Time}");
}

// Output:
// Age: 5 years, 11 months, 16 days, 00:00:00

// Other Outputs:
// 02/28/2020:L - 02/29/2020:L    Age: 0 years, 0 months, 1 days, 00:00:00
// 02/29/2020:L - 02/29/2020:L    Age: 0 years, 0 months, 0 days, 00:00:00
// 02/29/2020:L - 03/01/2020:L    Age: 0 years, 0 months, 1 days, 00:00:00
// 02/29/1960:L - 02/28/2021:N    Age: 60 years, 11 months, 28 days, 00:00:00
// 02/29/1960:L - 03/01/2021:N    Age: 61 years, 0 months, 1 days, 00:00:00

// With Time Component:
// 01/05/2020 07:28:12:L - 02/05/2022 06:30:15:N    Age: 2 years, 0 months, 30 days, 23:02:03
// 02/05/2020 07:28:12:L - 01/05/2022 06:30:15:N    Age: 1 years, 10 months, 28 days, 23:02:03
// 02/05/2020 23:59:59:L - 01/06/2022 00:00:00:N    Age: 1 years, 11 months, 0 days, 00:00:01
// 02/05/2021 05:28:12:N - 02/05/2021 06:30:15:N    Age: 0 years, 0 months, 0 days, 01:02:03
// 02/05/2021 07:28:12:N - 02/06/2021 06:30:15:N    Age: 0 years, 0 months, 0 days, 23:02:03
// 02/29/2016 00:00:00:L - 02/28/2021 00:00:01:N    Age: 4 years, 11 months, 28 days, 00:00:01
// 02/29/2016 00:00:02:L - 02/28/2021 00:00:01:N    Age: 4 years, 11 months, 27 days, 23:59:59
// 02/29/2016 00:00:00:L - 03/01/2021 00:00:01:N    Age: 5 years, 0 months, 1 days, 00:00:01
// 02/29/2016 00:00:02:L - 03/01/2021 00:00:01:N    Age: 5 years, 0 months, 0 days, 23:59:59
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.1 933 3/15/2024
1.4.0 1,999 2/9/2024
1.3.0 39,126 6/23/2022
1.2.2 4,549 10/1/2021
1.2.1 357 9/25/2021
1.2.0 307 9/24/2021
1.1.2 356 9/23/2021
1.1.1 341 9/20/2021
1.1.0 371 9/20/2021

For sample usage see the REDME file under the repository.