-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any scope in this repository for converting "humanized" text back to time.Time ? #73
Comments
That sounds like a huge, fuzzy task. I've done this in projects before in https://github.com/dustin/seriesly/blob/master/timelib/time.go#L110-L129 -- but that was for a relatively small number of timestamp formats that are constrained. If you want to try to guess what time someone is communicating (e.g., |
But it could work on a very basic level, right? like |
It seems incomplete to be able to produce relative time phrases but to then not be able to parse them (e.g. "6 months ago"). |
Given that |
That's a consideration of the person using it. The same could be said for any relative distance. Obviously, such a thing would not make sense and, in most cases, is not a concern. No one stores a string saying "6 months ago" in the database for timestamps, nor does anyone store such a string in the database expecting to decode it twenty years later back to the original time. Taken from the other direction, you're supposing that it's impossible that anyone should ever have the need, which is not accurate. Just write the provision and let the people use it that need it. That's Separation of Concerns, baby. I wrote a project to manage this six months ago. It also handles both absolute and relative quantities ("twenty minutes" vs "twenty minutes from now"): https://github.com/dsoprea/go-time-parse https://github.com/dsoprea/go-time-parse/blob/master/parse_test.go:
It doesn't have to be complicated. The standard use-case doesn't have to involve fuzziness at all. Once again, it really depends on what people are expecting to use it for, and they're gonna only use it for a use-case that makes sense, e.g. simple configurations and command-line arguments. If this project doesn't provide something that falls within the standard range of something that some developers need, they're just gonna have to write it themselves, where you'd be doing them a favor by preventing them from having to do so. Dustin |
No description provided.
The text was updated successfully, but these errors were encountered: