@dipaktelangre/age-calculator

Calculate age from given date of birth

Usage no npm install needed!

<script type="module">
  import dipaktelangreAgeCalculator from 'https://cdn.skypack.dev/@dipaktelangre/age-calculator';
</script>

README

Introduction

Javascript library to calculate age from date of birth

Installation

npm install @dipaktelangre/age-calculator

Usage

node

var { AgeCalculator } = require("@dipaktelangre/age-calculator"); // undefined
AgeCalculator.getAge(new Date("01/01/1990")); //{ years: 30, months: 6, days: 3 }
AgeCalculator.getAgeIn(new Date("01/01/1990"), "years"); // 30
AgeCalculator.getAgeIn(new Date("01/01/1990"), "weeks"); // 1591
AgeCalculator.getAgeIn(new Date("01/01/1990"), "month"); //366

typescript

import { AgeCalculator } from "@dipaktelangre/age-calculator";
AgeCalculator.getAge(new Date("01/01/1990")); //{ years: 30, months: 6, days: 3 }
AgeCalculator.getAgeIn(new Date("01/01/1990"), "years"); // 30
AgeCalculator.getAgeIn(new Date("01/01/1990"), "weeks"); // 1591
AgeCalculator.getAgeIn(new Date("01/01/1990"), "month"); //366

Build

npm run build

Test

npm run test
npm run test:tdd

Contribute

If you would like to contribute, you are welcome. Clone repository and open pull request.