
轻量级 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.18carbon,julian,lunar,persian从值传递改成指针传递新增
ZoneName方法获取时区名称新增
HasError方法判断是否有错误新增
IsNil方法判断是否是nil新增
Copy方法对carbon进行深度复制新增示例文件
xxx_example.go新增
constant.go文件,将常量从carbon.go文件迁移到此文件默认全局时区从
Local更改为UTCOffset方法更名为ZoneOffsetIsSetTestNow方法更名为IsTestNowUnSetTestNow方法更名为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