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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding: support unix time #1980

Merged
merged 4 commits into from
Jul 10, 2019

Commits on Jul 6, 2019

  1. Configuration menu
    Copy the full SHA
    e29ae3a View commit details
    Browse the repository at this point in the history
  2. binding: support unix time

    add test file
    modify readme
    
    ```golang
    package main
    
    import (
            "fmt"
            "github.com/gin-gonic/gin"
            "time"
    )
    
    type shareTime struct {
            CreateTime time.Time `form:"createTime" time_format:"unixNano"`
            UnixTime   time.Time `form:"unixTime" time_format:"unix"`
    }
    
    func main() {
            r := gin.Default()
            unix := r.Group("/unix")
    
            testCT := time.Date(2019, 7, 6, 16, 0, 33, 123, time.Local)
            fmt.Printf("%d\n", testCT.UnixNano())
    
            testUT := time.Date(2019, 7, 6, 16, 0, 33, 0, time.Local)
            fmt.Printf("%d\n", testUT.Unix())
    
            unix.GET("/nano", func(c *gin.Context) {
                    s := shareTime{}
    
                    c.ShouldBindQuery(&s)
    
                    if !testCT.Equal(s.CreateTime) {
                            c.String(500, "want %d got %d", testCT.UnixNano(), s.CreateTime)
                            return
                    }
    
                    c.JSON(200, s)
            })
    
            unix.GET("/sec", func(c *gin.Context) {
                    s := shareTime{}
    
                    c.ShouldBindQuery(&s)
    
                    if !testUT.Equal(s.UnixTime) {
                            c.String(500, "want %d got %d", testCT.Unix(), s.UnixTime)
                            return
                    }
    
                    c.JSON(200, s)
    
            })
    
            r.Run()
    }
    
    ```
    guonaihong committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    83e0c6f View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2019

  1. Contraction variable scope

    guonaihong committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    4773be0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    edcbaa6 View commit details
    Browse the repository at this point in the history