mirror of
				https://github.com/theoludwig/libcproject.git
				synced 2025-05-21 23:21:15 +02:00 
			
		
		
		
	| @@ -329,3 +329,11 @@ struct date *date_get_now_local() { | ||||
|  | ||||
|   return date; | ||||
| } | ||||
|  | ||||
| uint16_t date_get_age(struct date *birth_date, struct date *current_date) { | ||||
|   uint16_t age = current_date->year - birth_date->year; | ||||
|   if (current_date->month < birth_date->month || (current_date->month == birth_date->month && current_date->day < birth_date->day)) { | ||||
|     age--; | ||||
|   } | ||||
|   return age; | ||||
| } | ||||
|   | ||||
| @@ -338,4 +338,13 @@ struct date *date_get_now_utc(); | ||||
|  */ | ||||
| struct date *date_get_now_local(); | ||||
|  | ||||
| /** | ||||
|  * @brief Calculates the age of a person based on their birth date. | ||||
|  * | ||||
|  * @param birth_date | ||||
|  * @return uint16_t | ||||
|  * @since v5.1.0 | ||||
|  */ | ||||
| uint16_t date_get_age(struct date *birth_date, struct date *current_date); | ||||
|  | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user