
轻量级 Golang 时间处理库 Carbon 2.6.0 发布

carbon 是一个轻量级、语义化、对开发者友好的 Golang 时间处理库,提供了对时间穿越、时间差值、时间极值、时间判断、星座、星座、农历、儒略日 / 简化儒略日、波斯历 / 伊朗历的支持。
carbon 目前已捐赠给 dromara[1] 开源组织,已被 awesome-go[2] 收录,并获得 gitee[3] 2024 年最有价值项目(GVP[4])和 gitcode[5] 2024 年度 G-Star[6] 项目,如果您觉得不错,请给个 star 吧
github.com/dromara/carbon[7]
gitee.com/dromara/carbon[8]
gitcode.com/dromara/carbon[9]
更新日志
golang
最低版本依赖升级到1.18
carbon
,julian
,lunar
,persian
从值传递改成指针传递新增
ZoneName
方法获取时区名称新增
HasError
方法判断是否有错误新增
IsNil
方法判断是否是nil
新增
Copy
方法对carbon
进行深度复制新增示例文件
xxx_example.go
新增
constant.go
文件,将常量从carbon.go
文件迁移到此文件默认全局时区从
Local
更改为UTC
Offset
方法更名为ZoneOffset
IsSetTestNow
方法更名为IsTestNow
UnSetTestNow
方法更名为CleanTestNow
移除
Location
方法,由Timezone
方法替代更改
IsValid
和IsInvalid
方法判断逻辑,zero time
不再视为无效时间设置全局默认时区时同步更新
time.Local
重构
database.go
,移除carbon.DateTime
、carbon. DateTimeMilli
、carbon.DateTimeMicro
、carbon.DateTimeNano
、carbon. Date
、carbon.DateMilli
、carbon.DateMicro
、carbon.DateNano
、carbon.Time
、carbon.TimeMilli
、carbon.TimeMicro
、carbon.TimeNano
、carbon.Timestamp
、carbon.TimestampMilli
、carbon.TimestampMicro
、carbon.TimestampNano
字段类型, 使用泛型字段替代以实现MarshalJSON/UnmarshalJSON
时自定义输出格式
参考资料
[1]
dromara: https://dromara.org/
[2]
awesome-go: https://github.com/avelino/awesome-go#date-and-time
[3]
gitee: https://gitee.com
[4]
GVP: https://gitee.com/gcp
[5]
gitcode: https://gitcode.com
[6]
G-Star: https://gitcode.com/g-star
[7]
github.com/dromara/carbon: https://github.com/dromara/carbon
[8]
gitee.com/dromara/carbon: https://gitee.com/dromara/carbon
[9]
gitcode.com/dromara/carbon: https://gitcode.com/dromara/carbon