carbon
carbon copied to clipboard
A simple, semantic and developer-friendly golang package for time
设置了全局默认设置 ``` carbon.SetDefault(carbon.Default{ Layout: carbon.DateTimeLayout, Timezone: carbon.UTC, WeekStartsAt: carbon.Monday, Locale: "zh-CN", }) ``` 结构体声明 ``` type YHXDayUp struct { ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` DeviceId int32 `json:"device_id" comment:"设备id"` CreatedAt carbon.Carbon `gorm:"column:created_at;type:timestamp"...
Hello, I encountered an issue with the following code: ```go c := struct { ActiveTime carbon.TimestampMilli `json:"activeTimeStamp"` }{} err := json.Unmarshal([]byte(`{"activeTimeStamp":null}`), &c) fmt.Println(c.ActiveTime, c.ActiveTime.IsValid(), c.ActiveTime.IsZero(), err) ``` golang version: **such...
在使用一些复杂的 SQL 时,如:时间分组、自定义字段等,非基础类型的字段值通常会被设置为 `[]byte` ,我们需要自行实现 `Scanner` 接口解析其值,但是在 carbon 中,只解析值为 `time.Time` 类型,并未解析 `[]byte` ,导致使用复杂 SQL 时,无法实现解析 See: https://github.com/golang-module/carbon/blob/165bda517b50bc3fd41f952c0d53c7478fbf2db3/database.go#L10-L21 
 This is the dependency graph obtained by analyzing the go program using https://gsa.zxilly.dev/, which shows that carbon takes up a lot of space.