mirror of
https://github.com/cowardmrx/dateparse_tag.git
synced 2025-01-18 18:56:49 +08:00
27 lines
404 B
Go
27 lines
404 B
Go
|
package dateparse_tag
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type User struct {
|
||
|
Name string `json:"name"`
|
||
|
BirthDay string `json:"birth_day" format_date:"default"`
|
||
|
}
|
||
|
|
||
|
func TestNewDateParseTag(t *testing.T) {
|
||
|
u := new(User)
|
||
|
|
||
|
u.Name = "张三"
|
||
|
u.BirthDay = time.Now().String()
|
||
|
|
||
|
t.Logf("old user : %v", u)
|
||
|
|
||
|
dp := NewDateParseTag(WithTagName("format_date"))
|
||
|
|
||
|
dp.Parse(u, u)
|
||
|
|
||
|
t.Logf("new user %v", u)
|
||
|
}
|