mirror of
				https://github.com/theoludwig/theoludwig.git
				synced 2025-10-14 20:23:25 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			454 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			454 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| export const DIVLO_BIRTHDAY = new Date('2003-03-31')
 | |
| 
 | |
| /**
 | |
|  * Calculates the age of a person based on their birth date
 | |
|  * @param birthDate
 | |
|  * @returns
 | |
|  */
 | |
| export const getAge = (birthDate: Date): number => {
 | |
|   const today = new Date()
 | |
|   let age = today.getFullYear() - birthDate.getFullYear()
 | |
|   const month = today.getMonth() - birthDate.getMonth()
 | |
|   if (month < 0 || (month === 0 && today.getDate() < birthDate.getDate())) {
 | |
|     age--
 | |
|   }
 | |
|   return age
 | |
| }
 |