-
Notifications
You must be signed in to change notification settings - Fork 13
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
Match time format #8
Comments
Hi @cyucelen. What you're asking for is a function that given some string returns witch layout corresponds to it, or a func that converts one format to another? |
Hi @MarcoAntonioSilveira. I just updated the description with some detail about what are we expecting from this feature. |
@cyucelen I must pay attention to the date being valid or only match the layout without worrying about the correctness of the date? (Mon Feb 31 23:59:59 2006 with ANSIC layout would be marked in this case) |
You don't need to check if its a valid date or not. Just match for the layout. Validation can be another feature for another issue and can be implemented later. |
@cyucelen Could you assing me this issue? I'm working on it |
@MarcoAntonioSilveira looks like time.Stamp matches more than one layouts' parts (i.e. ANSIC, UnixDate, StampMilli, StampMicro, StampNano). I created a new branch |
@cyucelen maybe we can filter those cases with regexps. The conflicts with other stamps (StampMilli, etc) looks like it's easy to solve, some time soon I will try some ideas. But in the ANSIC and UnixDate cases, is it really a wrong match? The pattern is there. In case you do think those cases should be treated, maybe it's possible to do it with regexps to avoid matching when preceded by the abbreviations of days of the week, since these doesn't conflict with other real worlds (I guess). What do you think? |
Lets fix the overlap with StampMilli, StampMicro and Stampnano first. Then we can discuss ANSIC and UnixDate cases whether its a problem or not. |
Any updates @MarcoAntonioSilveira, do you need help? |
@cyucelen sorry, I've been really busy lately. My solution to the overlap with the other stamps was using negative lookahead to filter out the ".[0-9]" part, but golang's regexp package doesn't support negative lookaheads. To date I couldn't think of some way to do it using regexp without including the whitespace after the layout in the match. Take a look: https://regex101.com/r/tDMEIN/1 If you have any suggestions, it would be great. |
Create a matcher which takes one of the time layouts of golang standard time library and matches them in given string.
An example:
Distinct implementations can be written for each format. We can discuss to split the issue to fine grained pieces on the way with respect to complexity.
The text was updated successfully, but these errors were encountered: