Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

75%
+4 −0
Challenges Calculate a person's age

Challenge Given a date with day, month and year, calculate how old a person born on that day would be today. Input can be in any reasonable format(params, array, date object). Input will never b...

0 answers  ·  posted 4y ago by Razetime‭

Question code-golf date
#1: Initial revision by user avatar Razetime‭ · 2021-01-02T08:21:49Z (almost 4 years ago)
Calculate a person's age
# Challenge
Given a date with day, month and year, calculate how old a person born on that day would be today.

Input can be in any reasonable format(params, array, date object).

Input will never be invalid.

Output must consist of years, months and days in any order you specify.

Date and Time libraries are allowed.

# Testcases
These are with respect to 2nd January 2021. It will change depend on when you answer. Use [this site](https://www.calculatestuff.com/miscellaneous/age-calculator) to verify your answers.
```
1st September 2003 - 17 years 4 months 1 day 
6th December 2016 - 4 years 0 months 27 days 
12th April 1985 - 35 years 1 month 28 days
```
[Here are the testcases in a more suitable format.](https://dzaima.github.io/paste#0LYzBCcBACAT/W4UFCN4aI7GW4/pvI0ry2oFZhlbma11Iow8lesNYzw1saunog51KH87mptC5HIBS8hWELn9BQka/)