add Dark mode and fix get age function
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import {Birthday} from "./types.ts";
|
||||
|
||||
export const arrayRange = (end: number, start = 0) => {
|
||||
const array = []
|
||||
for (let i = start; i <= end; i++) {
|
||||
@@ -10,4 +12,13 @@ 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 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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user