Add type to parse date and time
I have added a new type ParseDateAndTime to parse timestamps from DisplayString and report it as unix timestamp.
Please have a look and report if something is missing.
This fixes #1232
For now it uses the go time.Parse() function. If we want to swap it out there are some packages.
- https://github.com/golang-module/carbon
- https://github.com/jinzhu/now
What do you think?
Nice, I like it so far. I haven't had a chance to evaluate the parser libraries.
I personally prefer strftime style parsing. I sent a couple of PRs to https://github.com/lestrrat-go/strftime to see if the maintainer is still active.
What do you think @bastischubert? Do you prefer Go or strftime style date parsing syntax?
I'm not in favor of any specific parsing syntax - whatever works and doesn't introduce unnecessary complexity if ok (-:
@SuperQ did you find the time to have a look at the time parser libraries? Do I have to change something or can this PR be merged?
I looked over https://github.com/lestrrat-go/strftime, it seems reasonable. I'm fine with either library, but I live a slight preference for strftime.
Thanks for you reply. I will update the PR and use the strftime functions to parse the date and time. But before I change the code. Do you see any reason why we should provide an config option to specify the format type?
Example:
datetime_format_type: go | strftime
Adding multiple parser options is probably a bit more complexity than necessary. I'd like to start with one parser and see how things evolve.
Had to use https://github.com/itchyny/timefmt-go instead of https://github.com/lestrrat-go/strftime because it does not support parsing lestrrat-go/strftime#22