theTardigrade / golang-age

This Go package is used to determine an age from a given date.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

golang-age

This is a simple Go package for determining age.

The most useful public function is CalculateToNow, which determines an age based on the duration between a given date and the present moment. There is also a more general function named Calculate, which determines an age based on the duration between any two given dates.

Go Reference Go Report Card

Example

package main

import (
	"time"
	"fmt"

	age "github.com/theTardigrade/golang-age"
)

func main() {
	const day, month, year = 27, 5, 1960

	date := time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
	dateAge := age.CalculateToNow(date)

	fmt.Println(dateAge)
}

Support

If you use this package, or find any value in it, please consider donating:

ko-fi

About

This Go package is used to determine an age from a given date.

License:GNU General Public License v3.0


Languages

Language:Go 100.0%