Recipe 36 | Parsing Time Strings |
Task
You’re working in a news agency, helping with data storage. Phil, the product manager, assigns an issue for you:
We’d like to help journalists search for articles in a specific time. The journalists aren’t that tech savvy, so we’d like to support more natural language in the queries. Here are some examples:
- 2 weeks ago
- today
- 5 hours ago
- 2020-03-02T11:47
Since we have customers from all over the world, we need to support time zones as well. The time zone will be in [] at the end of the query—for example, today [Australia/Sydney]. If time zone is not specified, use UTC.
You start by going over the documentation of the time package and then start to code.
Solution
You start by looking at time zones. You decide to use ...
Get Effective Go Recipes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.