-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
time.RFC3339 #566
Comments
@jc-fireball sorry for the slow response on this! The Go JSON marshaler controls this behavior via the You should be able to create a custom type wrapping |
Only the time.Time in header is in different way which allows us to override the format but not in other places like json field. |
@jc-fireball that specific code you linked to is Huma's custom handling of parameters (path/query/header/cookie). You can change that time format like this using Go's time formatting: type MyInput struct {
MyTime time.Time `query:"myTime" timeFormat:"..."`
} Keep in mind though this is not for the JSON body, which is controlled by the t := time.Now()
t = t.Add(123 * time.Millisecond)
b, _ := json.Marshal(t)
fmt.Println(string(b)) // prints with milliseconds
t = t.Truncate(time.Second)
b, _ = json.Marshal(t)
fmt.Println(string(b)) // prints without milliseconds |
Hi
We've been migrating to huma. We notice the default time format is using RFC3339nano in json response. Is there anyway we can set the time format in json to time.RFC3339
The text was updated successfully, but these errors were encountered: