age

package module
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2023 License: GPL-3.0 Imports: 2 Imported by: 1

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Calculate

func Calculate(startTime, endTime time.Time) int

Calculate returns an integer-value age based on the duration between the two times that are given as arguments.

func CalculateToNow added in v1.3.0

func CalculateToNow(givenTime time.Time) int

Calculate returns an integer-value age based on the duration between the given time and the present time.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL