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

Comments on Calculate a person's age

Post

Calculate a person's age

+4
−0

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 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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (2 comments)
General comments
Corsaka‭ wrote over 3 years ago

We can specify what the input can be? Or we must account for any input?

Razetime‭ wrote over 3 years ago

@Corsaka You must specify the input format. The testcases are formatted that way for readability.