The idea is this: Write a function to print the length of time from now/today's date (at the time the function is called) until a date supplied as an argument.
Assumptions:
- Input date will always be tomorrow or later, in the future.
- Input date will never be more than 10 years in the future.
Rules:
- Output must be in this format: "[z year(s)], [x month(s)], y day(s) until -Input Date-"
- Output time frame (day/month/year) must be pluralized correctly. i.e.
1 month
, not1 months
- Input can be in whichever date format you prefer (3/15/12 - March 15, 2012 - 2012.03.15).
Example: Assuming program is run on March 15, 2012:
- Input date of
3/20/12
=5 days until 3/20/12
- NOT Input date of
4/16/12
=1 month, 1 days until 3/20/12
- Input date of
2012.04.20
=1 month, 5 days until 2012.04.20
- NOT Input date of
2012.04.20
=36 days until 2012.04.20
- Input date of
10/31/17
=5 years, 7 months, 16 days until 10/31/17
- Input date of
3/15/13
=1 year until 3/15/13
This is code golf, so shortest length code wins.
I suppose for the sake of having a deadline, I will be selecting an answer on:
March 23, 2012!
(This is my first CG question, so I'll be happy to correct any question errors on my part!)
now until <input time>
:p \$\endgroup\$ – Griffin Mar 15 '12 at 22:16now-<input time>
\$\endgroup\$ – PhiNotPi Mar 15 '12 at 22:23