Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 QueryParser does not support time.Time ? #1378

Closed
gopkg-dev opened this issue Jun 10, 2021 · 5 comments
Closed

馃 QueryParser does not support time.Time ? #1378

gopkg-dev opened this issue Jun 10, 2021 · 5 comments

Comments

@gopkg-dev
Copy link

Question description

QueryParser does not support time.Time

Code snippet Optional

package main

import (
	"time"

	"github.com/gofiber/fiber/v2"
)

func main() {
	app := fiber.New()

	type TestQuery struct {
		CreateTime time.Time `query:"create_time"`
	}

	app.Get("/", func(c *fiber.Ctx) error {
		var testQuery TestQuery
		err := c.QueryParser(&testQuery)
		if err != nil {
			return err
		}
		return c.JSON(testQuery)
	})

	app.Listen(":3000")
}
Error  ->   schema: error converting value for "create_time". Details: parsing time "2006-01-02T15:04:05Z07:00": extra text: "07:00"
@welcome
Copy link

welcome bot commented Jun 10, 2021

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

http://localhost:3000/?create_time=2006-01-02T15:04:05Z

so if you choose the right format it runs

the gorilla schema parser can do the trading
https://github.com/gorilla/schema/blob/8285576f31afd6804df356a38883f4fa05014373/decoder_test.go#L1861

but i think it might be better to register a method for the conversion, which is not possible at the moment
#1100

@gopkg-dev
Copy link
Author

Thanks, i get it

@ReneWerner87
Copy link
Member

@ReneWerner87
Copy link
Member

its in the newest release https://github.com/gofiber/fiber/releases/tag/v2.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants