dateparse icon indicating copy to clipboard operation
dateparse copied to clipboard

Can dateparse return the formatters used?

Open estenssoros opened this issue 5 years ago • 1 comments

Hi! New to open-source here, so not sure if this is the best place to ask a question about your project. Let me know if i need to direct my question elsewhere.

After parsing a date string, is it possible to return the formatters used for parsing? For example, I have a large file of dates all the same unknown format. It would probably be much faster to parse the first date, figure out what formatter it's using and apply that to subsequent dates through time.Parse.

I asked this same question about python's dateutil.parser but learned that what I was aksing is impossible from the base package. https://stackoverflow.com/questions/49197938/return-directives-used-by-dateutil-parser. We could follow the guidance from this answer: https://stackoverflow.com/a/49198112/6146337 to implement.

What do you think?

estenssoros avatar Aug 30 '19 18:08 estenssoros

https://godoc.org/github.com/araddon/dateparse#ParseFormat You can call ParseFormat, store the resulting string, and use it with time.Parse thereafter

troyspencer avatar Sep 10 '19 01:09 troyspencer