import {Birthday} from "./types.ts"; export const arrayRange = (end: number, start = 0) => { const array = [] for (let i = start; i <= end; i++) { array.push(i) } return array } export const pad = (number: number, pad = 2, char = '0') => { return (new Array(pad).join(char) + number).slice(-pad) } export const MONTHS = ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] export const getAge = (birthday: Birthday) => { const age = ((new Date()).getTime() - (new Date(`${birthday.year}-${birthday.month}-${birthday.day}`)).getTime()) / 1000 / 60 /60 /24 /365.75 if (age < 3) { return age.toFixed(age < 3 ? 1 : 0) } else { return Math.floor(age).toFixed() } }