You are a developer on a task manager app. Your users can create tasks and those tasks, in particular, have a time and date.
To provide a enhanced experience to your users upon task creation, you want the task date to be a free text field. A user would input strings such as in 2 days
, 3 hours ago
, tomorrow
, on december 5th at noon
, and you would save that information as a date object in the system.
Parse a user input and return a Date object representing the date / time expressed by the user input.
tomorrow
in 3 hours
2 weeks ago
last month
(current date: 2015-12-25 14:00:00
)
2015-12-26 14:00:00
2015-12-25 17:00:00
2015-12-11 14:00:00
2015-11-25 14:00:00
We don't expect a complete solution, covering all possible imputs one can imagine. The solution should handle some cases as you see fit, including at least the ones in the previous example input.
You should focus on creating a well-designed solution that could easily be exented to support new inputs.
You can implement the solution in any programming language.
A JS or Ruby solution would be preferable if one of those language is part of your skillset, but you should prefer a language you know well enough, so you can show off your skills :)