-
Notifications
You must be signed in to change notification settings - Fork 63
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
Any way to specify additional formats to use when unmarshalling strfmt.DateTime values? #70
Comments
You can replace registered type in the default dictionary to a new datetime type. This is a very common ask. |
Hi @casualjim, thanks for the quick reply... Could you perhaps provide a brief example of how I might do this so that I could "override" the Unmarshal-related functions to support additional formats? I'm not familiar with replacing types in the default dictionary. Thanks in advance! |
Every one of the strfmt types registers itself into a dictionary. https://github.com/go-openapi/strfmt/blob/master/time.go#L31-L34 IMO the right way to solve is by exporting this: https://github.com/go-openapi/strfmt/blob/master/time.go#L75 |
Closes go-openapi#70 This commit exports the DateTimeFormats variable so that users can modify the set of formats used by ParseDateTime, as in this example: strfmt.DateTimeFormats = append(strfmt.DateTimeFormats, "2006-01-02T15:04Z0700") Signed-off-by: Phil Adams <[email protected]>
@casualjim PR opened. Let me know if anything needs to change. Thanks for your help on this. |
Thanks for getting that merged in so quickly! |
Hi, I have a question about the strfmt.DateTime type.
Is there any way that I can leverage the unmarshal functionality of strfmt.DateTime while supporting one or more additional formats for date-time values? Logically, what I'd like to do is add one or more formats to the "dateTimeFormats" list that's defined in time.go.
Failing that, is there perhaps a way that I could define my own UnmarshalJSON() function that would be used instead of the one defined in the strfmt package?
Thanks
The text was updated successfully, but these errors were encountered: