Is there a general parser to parse "... back" strings and turn them into DateTime objects?
Possible suggestions:
- 1 year | @count years (and 1 week | @count weeks) ago
- 1 week | @count weeks (and 1 day | @count days) ago
- 1 day | @count days (and 1 hour | @count hours) ago
- 1 hour | @count hours ago (and 1 min. @count min) ago
- 1 minute | @count min ago (and 1 sec | @count sec) ago
- 1 s | @count sec ago
So, this is either a combination of two (Foo and Bar back), or only one (Foo back). And it can be singular or multiple.
Ruby DateTime::parse() cannot handle this, and DateTime::strptime() cannot.
I hope for a gem or fragment somewhere that handles this.
Else I will need to create my own parser, in which case a pointer to a way to create my own DateTime Parsers will be very welcome.
Sidenote: For Future Reference: these are timestrings created by Drupals. Spacing between formats
berkes
source share