Releases: dromara/carbon
v2.5.10
English
- Upgrade
go
version from1.18
to1.21
SetLanguage
method ofCarbon
struct add check for invalidLanguage
structParse
method ofCarbon
struct add support forMySQL
/Postgres
/SQLite
time format stringParse
/ParseByLayout
/ParseByFormat
methods ofCarbon
struct change the return value fromnil
toempty
carbon when parsing anempty
stringCarbon
struct addIsEmpty
method to determine if it is anempty
carbonCarbon
struct addClearTestNow
method to replaceCleanTestNow
,CleanTestNow
will be removed in the futureCarbon
struct addParseByLayouts
method to replaceParseWithLayouts
,ParseWithLayouts
will be removed in the futureCarbon
struct addParseByFormats
method to replaceParseWithFormats
,ParseWithFormats
will be removed in the futureCarbon
struct removeGormDataType
method and changeValue
/MarshalJSON
methods frompointer
receiver tovalue
receiverLayoutType[T]
struct removeGormDataType
method and changeValue
/MarshalJSON
methods frompointer
receiver tovalue
receiverFormatType[T]
struct removeGormDataType
method and changeValue
/MarshalJSON
methods frompointer
receiver tovalue
receiverTimestampType[T]
struct removeGormDataType
method and changeValue
/MarshalJSON
methods frompointer
receiver tovalue
receiverSetResources
method ofLanguage
struct add check invalid resources- Add
curd
integration testing forgorm
, currently coveringMySQL
/Postgres
/SQLite
- Replace
github.com/stretchr/testify/assert
withgithub.com/stretchr/testify/suite
for unit testing
中文
- 将
Go
最低版本要求从1.18
提升到1.21
Carbon
结构体的SetLanguage
方法增加对非法Language
结构体的判断Carbon
结构体的Parse
方法增加对MySQL
/Postgres
/SQLite
时间格式字符串的解析支持Carbon
结构体的Parse
/ParseByLayout
/ParseByFormat
方法解析空字符串
时返回值从nil
更改成空carbon
Carbon
结构体新增IsEmpty
方法用于判断是否为空carbon
Carbon
结构体新增ClearTestNow
方法替代CleanTestNow
,CleanTestNow
方法未来将移除Carbon
结构体新增ParseByLayouts
方法替代ParseWithLayouts
,ParseWithLayouts
方法未来将移除Carbon
结构体新增ParseByFormats
方法替代ParseWithLayouts
,ParseWithFormats
方法未来将移除Carbon
结构体移除GormDataType
方法, 并将Value
/MarshalJSON
方法从指针接收者改成值接收者LayoutType[T]
结构体移除GormDataType
方法, 并将Value
/MarshalJSON
方法从指针
接收者改成值
接收者FormatType[T]
结构体移除GormDataType
方法, 并将Value
/MarshalJSON
方法从指针
接收者改成值
接收者TimestampType[T]
结构体移除GormDataType
方法, 并将Value
/MarshalJSON
方法从指针
接收者改成值
接收者Language
结构体的SetResources
方法增加对非法资源的判断- 新增对
gorm
的curd
集成测试,目前已覆盖MySQL
/Postgres
/SQLite
- 使用
github.com/stretchr/testify/assert
替换github.com/stretchr/testify/suite
进行单元测试
v2.6.4
English
-
Fix panic when database field type was
nil
-
Split
database_types.go
intotype_carbon.go
,type_layout.go
,type_format.go
,type_timestamp.go
-
Rename
LayoutFactory
interface toLayoutTyper
andSetLayout
method toLayout
-
Rename
FormatFactory
interface toFormatTyper
andSeFormat
method toFormat
-
Rename
TimestampFactory
interface toTimestampTyper
andSePrecision
method toPrecision
-
Add
b.ResetTimer()
in benchmark test files -
Add
Copy
method forLanguage
struct -
Add
carbon.Timestamp
type alias andcarbon.NewTimestamp
method -
Add
carbon.TimestampMilli
type alias andcarbon.NewTimestampMilli
method -
Add
carbon.TimestampMicro
type alias andcarbon.NewTimestampMicro
method -
Add
carbon.TimestampNano
type alias andcarbon.NewTimestampNano
method -
Add
carbon.DateTime
type alias andcarbon.NewDateTime
method -
Add
carbon.DateTimeMicro
type alias andcarbon.NewDateTimeMicro
method -
Add
carbon.DateTimeMilli
type alias andcarbon.NewDateTimeMilli
method -
Add
carbon.DateTimeNano
type alias andcarbon.NewDateTimeNano
method -
Add
carbon.Date
type alias andcarbon.NewDate
method -
Add
carbon.DateMilli
type alias andcarbon.NewDateMilli
method -
Add
carbon.DateMicro
type alias andcarbon.NewDateMicro
method -
Add
carbon.DateNano
type alias andcarbon.NewDateNano
method -
Add
carbon.Time
type alias andcarbon.NewTime
method -
Add
carbon.TimeMilli
type alias andcarbon.NewTimeMilli
method -
Add
carbon.TimeMicro
type alias andcarbon.NewTimeMicro
method -
Add
carbon.TimeNano
type alias andcarbon.NewTimeNano
method
中文
-
修复数据库字段类型为
nil
时抛出异常的bug -
将
database_types.go
拆分成type_carbon.go
,type_layout.go
,type_format.go
,type_timestamp.go
-
将
LayoutFactory
接口重命名为LayoutTyper
和SetLayout
方法重命名为Layout
-
将
FormatFactory
接口重命名为FormatTyper
和SetFormat
方法重命名为Format
-
将
TimestampFactory
接口重命名为TimestampTyper
和SetPrecision
方法重命名为Precision
-
性能测试文件增加
b.ResetTimer()
-
Language
结构体新增Copy
方法 -
新增
carbon.Timestamp
类型别名和carbon.NewTimestamp
方法 -
新增
carbon.TimestampMilli
类型别名和carbon.NewTimestampMilli
方法 -
新增
carbon.TimestampMicro
类型别名和carbon.NewTimestampMicro
方法 -
新增
carbon.TimestampNano
类型别名和carbon.NewTimestampNano
方法 -
新增
carbon.DateTime
类型别名和carbon.NewDateTime
方法 -
新增
carbon.DateTimeMicro
类型别名和carbon.NewDateTimeMicro
方法 -
新增
carbon.DateTimeMilli
类型别名和carbon.NewDateTimeMilli
方法 -
新增
carbon.DateTimeNano
类型别名和carbon.NewDateTimeNano
方法 -
新增
carbon.Date
类型别名和carbon.NewDate
方法 -
新增
carbon.DateMilli
类型别名和carbon.NewDateMilli
方法 -
新增
carbon.DateMicro
类型别名和carbon.NewDateMicro
方法 -
新增
carbon.DateNano
类型别名和carbon.NewDateNano
方法 -
新增
carbon.Time
类型别名和carbon.NewTime
方法 -
新增
carbon.TimeMilli
类型别名和carbon.NewTimeMilli
方法 -
新增
carbon.TimeMicro
类型别名和carbon.NewTimeMicro
方法 -
新增
carbon.TimeNano
类型别名和carbon.NewTimeNano
方法
v2.5.9
English
-
Fix panic when database field type was
nil
-
Split
database_types.go
intotype_carbon.go
,type_layout.go
,type_format.go
,type_timestamp.go
-
Rename
LayoutFactory
interface toLayoutTyper
andSetLayout
method toLayout
-
Rename
FormatFactory
interface toFormatTyper
andSeFormat
method toFormat
-
Rename
TimestampFactory
interface toTimestampTyper
andSePrecision
method toPrecision
-
Add
b.ResetTimer()
in benchmark test files -
Add
Copy
method forLanguage
struct -
Add
carbon.Timestamp
type alias andcarbon.NewTimestamp
method -
Add
carbon.TimestampMilli
type alias andcarbon.NewTimestampMilli
method -
Add
carbon.TimestampMicro
type alias andcarbon.NewTimestampMicro
method -
Add
carbon.TimestampNano
type alias andcarbon.NewTimestampNano
method -
Add
carbon.DateTime
type alias andcarbon.NewDateTime
method -
Add
carbon.DateTimeMicro
type alias andcarbon.NewDateTimeMicro
method -
Add
carbon.DateTimeMilli
type alias andcarbon.NewDateTimeMilli
method -
Add
carbon.DateTimeNano
type alias andcarbon.NewDateTimeNano
method -
Add
carbon.Date
type alias andcarbon.NewDate
method -
Add
carbon.DateMilli
type alias andcarbon.NewDateMilli
method -
Add
carbon.DateMicro
type alias andcarbon.NewDateMicro
method -
Add
carbon.DateNano
type alias andcarbon.NewDateNano
method -
Add
carbon.Time
type alias andcarbon.NewTime
method -
Add
carbon.TimeMilli
type alias andcarbon.NewTimeMilli
method -
Add
carbon.TimeMicro
type alias andcarbon.NewTimeMicro
method -
Add
carbon.TimeNano
type alias andcarbon.NewTimeNano
method
中文
-
修复数据库字段类型为
nil
时抛出异常的bug -
将
database_types.go
拆分成type_carbon.go
,type_layout.go
,type_format.go
,type_timestamp.go
-
将
LayoutFactory
接口重命名为LayoutTyper
和SetLayout
方法重命名为Layout
-
将
FormatFactory
接口重命名为FormatTyper
和SetFormat
方法重命名为Format
-
将
TimestampFactory
接口重命名为TimestampTyper
和SetPrecision
方法重命名为Precision
-
性能测试文件增加
b.ResetTimer()
-
Language
结构体新增Copy
方法 -
新增
carbon.Timestamp
类型别名和carbon.NewTimestamp
方法 -
新增
carbon.TimestampMilli
类型别名和carbon.NewTimestampMilli
方法 -
新增
carbon.TimestampMicro
类型别名和carbon.NewTimestampMicro
方法 -
新增
carbon.TimestampNano
类型别名和carbon.NewTimestampNano
方法 -
新增
carbon.DateTime
类型别名和carbon.NewDateTime
方法 -
新增
carbon.DateTimeMicro
类型别名和carbon.NewDateTimeMicro
方法 -
新增
carbon.DateTimeMilli
类型别名和carbon.NewDateTimeMilli
方法 -
新增
carbon.DateTimeNano
类型别名和carbon.NewDateTimeNano
方法 -
新增
carbon.Date
类型别名和carbon.NewDate
方法 -
新增
carbon.DateMilli
类型别名和carbon.NewDateMilli
方法 -
新增
carbon.DateMicro
类型别名和carbon.NewDateMicro
方法 -
新增
carbon.DateNano
类型别名和carbon.NewDateNano
方法 -
新增
carbon.Time
类型别名和carbon.NewTime
方法 -
新增
carbon.TimeMilli
类型别名和carbon.NewTimeMilli
方法 -
新增
carbon.TimeMicro
类型别名和carbon.NewTimeMicro
方法 -
新增
carbon.TimeNano
类型别名和carbon.NewTimeNano
方法
v2.6.3
English
- Fix bug with the same results in different countries using
IsWeekend
andIsWeekday
methods. - Fix bug
carbon.Parse("").StdTime()
cause a nil pointer panic. #294 - Change errors from
private
method topublic
method. - Change the default start date of the week from
Sunday
toMonday
- Change the year of
MinValue
from-9998
to1
- Change
weeksPerLongYear
constant toWeeksPerLongYear
- Add benchmark test files
xxx_bench_test.go
- Add
IsEpoch
method to report whether is a unix epoch time(1970-01-01 00:00:00 +0000 UTC). - Add
WeekEndsAt
method to get end day of the week. - Add
SetWeekendDays
method to set weekend days of the week. - Add
DefaultWeekStartsAt
global variable to store weekend days of the week.
中文
- 修复
IsWeekend
,IsWeekday
方法不同国家返回结果一致的 bug - 修复
StdTime
方法空指针引起的异常 #294 - 将错误方法由
私有
方法改成公开
方法 - 将一周默认开始日期从
周日
改成周一
- 将
MinValue
方法的年份从-9998
更改为1
- 将
weeksPerLongYear
常量更名为WeeksPerLongYear
- 新增性能测试文件
xxx_bench_test.go
- 新增
IsEpoch
方法用于判断是否是 UNIX 纪元时间(1970-01-01 00:00:00 +0000 UTC) - 新增
WeekEndsAt
方法用于获取一周的结束日期 - 新增
SetWeekendDays
方法用于设置一周周末日期 - 新增
DefaultWeekStartsAt
全局变量用于存储默认一周休息日
v2.5.8
English
- Fix bug with the same results in different countries using
IsWeekend
andIsWeekday
methods. - Change errors from
private
method topublic
method. - Change the default start date of the week from
Sunday
toMonday
- Change the year of
MinValue
from-9998
to1
- Change
weeksPerLongYear
constant toWeeksPerLongYear
- Add
IsEpoch
method to report whether is a unix epoch time(1970-01-01 00:00:00 +0000 UTC). - Add
WeekEndsAt
method to get end day of the week. - Add
SetWeekendDays
method to set weekend days of the week. - Add
DefaultWeekStartsAt
global variable to store weekend days of the week.
中文
- 修复
IsWeekend
,IsWeekday
方法不同国家返回结果一致的 bug - 将错误方法由
私有
方法改成公开
方法 - 将一周默认开始日期从
周日
改成周一
- 将
MinValue
方法的年份从-9998
更改为1
- 将
weeksPerLongYear
常量更名为WeeksPerLongYear
- 新增
IsEpoch
方法用于判断是否是 UNIX 纪元时间(1970-01-01 00:00:00 +0000 UTC) - 新增
WeekEndsAt
方法用于获取一周的结束日期 - 新增
SetWeekendDays
方法用于设置一周周末日期 - 新增
DefaultWeekStartsAt
全局变量用于存储默认一周休息日
v2.6.2
English
- Remove
hour
,Minute
,second
parameter inCreateFromLunar
,CreateFromPersian
methods - Change some format symbol definitions involves symbols such as
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
- Fix bug of incorrect judgment of
IsLeapMonth
in lunar calendar - Fix bug of
AtomFormat
andAtomLayout
return inconsistent value - Fix bug of
RFC3339Format
andRFC3339Layout
return inconsistent value time.Local
is not updated when setting global time zone- Add format symbol
o
to get time zone offset - Add
TimestampLayout
,TimestampMilliLayout
,TimestampMicroLayout
andTimestampNanoLayout
constants - Add
TimestampFormat
,TimestampMilliFormat
,TimestampMicroFormat
andTimestampNanoFormat
constants - Add
DateTimeMilli
,DateTimeMicro
,DateTimeNano
field types - Add
DateMilli
、DateMicro
、DateNano
field types - Add
TimeMilli
、TimeMicro
、TimeNano
field types - Fix missing timezone bug in
IsDST
method - Fix missing timezone bug
StartOfXXX
,EndOfXXX
methods - Fix missing timezone bug when converting other calendars to
Gregorian
calendar time.Local
is not updated when setting default timezone- Add
MaxDuration
,MinDuration
methods
中文
CreateFromLunar
,CreateFromPersian
方法去掉 hour, minute, second 参数- 更改部分格式符号定义,涉及到的符号有
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
- 修复农历中
IsLeapMonth
判断错误的 bug - 修复
AtomFormat
和AtomLayout
格式返回值不一致的 bug - 修复
RFC3339Format
和RFC3339Layout
格式返回值不一致的 bug - 设置全局默认时区时不再同步更新
time.Local
- 新增格式符号
o
来获取时区偏移量 - 新增
TimestampLayout
、TimestampMilliLayout
、TimestampMicroLayout
和TimestampNanoLayout
常量 - 新增
TimestampFormat
、TimestampMilliFormat
、TimestampMicroFormat
和TimestampNanoFormat
常量 - 新增
DateTimeMilli
、DateTimeMicro
、DateTimeNano
字段类型 - 新增
DateMilli
、DateMicro
、DateNano
字段类型 - 新增
TimeMilli
、TimeMicro
、TimeNano
字段类型 - 修复
IsDST
方法丢失时区的 bug - 修复
StartOfXXX
、EndOfXXX
部分方法丢失时区的 bug - 修复其他日历转化为公历时缺失时区的 bug
- 设置默认时区时不再同步更新
time.Local
- 新增
MaxDuration
、MinDuration
方法
v2.5.6
v2.5.5
English
-
golang
minimum version dependency upgraded to1.18
-
Change default global timezone from
Local
toUTC
-
Remove
hour
,Minute
,second
parameter inCreateFromLunar
,CreateFromPersian
methods -
Change some format symbol definitions involves symbols such as
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
-
Fix bug of incorrect judgment of
IsLeapMonth
in lunar calendar -
Fix bug of
AtomFormat
andAtomLayout
return inconsistent value -
Fix bug of
RFC3339Format
andRFC3339Layout
return inconsistent value -
Fix missing timezone bug in
IsDST
method -
Fix missing timezone bug
StartOfXXX
,EndOfXXX
methods -
Rename
Offset
method toZoneOffset
method -
Rename
IsSetTestNow
method toIsTestNow
method -
Rename
UnSetTestNow
method toCleanTestNow
method -
Remove
Location
method, replaced byTimezone
method -
Change the judgment logic of
IsValid
andIsInvalid
methods,zero time
is no longer considered invalid time -
Add
ZoneName
method to get the time zone name -
Add
HasError
method to check if there is an error -
Add
WeekStartsAt
method to get start day of the week -
Add
ParseWithLayouts
andParseWithFormats
methods -
Add format symbol
o
to get time zone offset
中文
-
golang
最低版本依赖升级到1.18
-
默认全局时区从
Local
更改为UTC
-
CreateFromLunar
,CreateFromPersian
方法去掉 hour, minute, second 参数 -
更改部分格式符号定义,涉及到的符号有
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
-
修复
IsDST
方法丢失时区的 bug -
修复
StartOfXXX
、EndOfXXX
部分方法丢失时区的 bug -
修复农历中
IsLeapMonth
判断错误的 bug -
修复
AtomFormat
和AtomLayout
格式返回值不一致的 bug -
修复
RFC3339Format
和RFC3339Layout
格式返回值不一致的 bug -
Offset
方法更名为ZoneOffset
-
IsSetTestNow
方法更名为IsTestNow
-
UnSetTestNow
方法更名为CleanTestNow
-
移除
Location
方法,由Timezone
方法替代 -
更改
IsValid
和IsInvalid
方法判断逻辑,zero time
不再视为无效时间 -
新增
ZoneName
方法获取时区名称 -
新增
HasError
方法判断是否有错误 -
新增
WeekStartsAt
方法获取周起始日期 -
新增
ParseWithLayouts
和ParseWithFormats
方法 -
新增格式符号
o
来获取时区偏移量
v2.6.2-rc1
English
- Remove
hour
,Minute
,second
parameter inCreateFromLunar
,CreateFromPersian
methods - Change some format symbol definitions involves symbols such as
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
- Fix bug of incorrect judgment of
IsLeapMonth
in lunar calendar - Fix bug of
AtomFormat
andAtomLayout
return inconsistent value - Fix bug of
RFC3339Format
andRFC3339Layout
return inconsistent value time.Local
is not updated when setting global time zone- Add format symbol
o
to get time zone offset - Add
TimestampLayout
,TimestampMilliLayout
,TimestampMicroLayout
andTimestampNanoLayout
constants - Add
TimestampFormat
,TimestampMilliFormat
,TimestampMicroFormat
andTimestampNanoFormat
constants - Add
DateTimeMilli
,DateTimeMicro
,DateTimeNano
field types - Add
DateMilli
、DateMicro
、DateNano
field types - Add
TimeMilli
、TimeMicro
、TimeNano
field types
中文
CreateFromLunar
,CreateFromPersian
方法去掉 hour, minute, second 参数- 更改部分格式符号定义,涉及到的符号有
U
,V
,X
,S
,T
Z
,u
,v
,x
,z
- 修复农历中
IsLeapMonth
判断错误的 bug - 修复
AtomFormat
和AtomLayout
格式返回值不一致的 bug - 修复
RFC3339Format
和RFC3339Layout
格式返回值不一致的 bug - 设置全局默认时区时不再同步更新
time.Local
- 新增格式符号
o
来获取时区偏移量 - 新增
TimestampLayout
、TimestampMilliLayout
、TimestampMicroLayout
和TimestampNanoLayout
常量 - 新增
TimestampFormat
、TimestampMilliFormat
、TimestampMicroFormat
和TimestampNanoFormat
常量 - 新增
DateTimeMilli
、DateTimeMicro
、DateTimeNano
字段类型 - 新增
DateMilli
、DateMicro
、DateNano
字段类型 - 新增
TimeMilli
、TimeMicro
、TimeNano
字段类型
v2.6.1
English
- Add
ParseWithLayouts
andParseWithFormats
methods - Rename
formatFactory
interface toFormatFactory
,formatFactory
interface toFormatFactory
,formatFactory
interface toFormatFactory
, and add type constraints - Change the return value of the
GormDataType
method of theLayoutType
,FormatType
,TimestampType
struct
totime
- Change
DateTime
,Date
,Time
types fromstruct
tostring
- Change
Timestamp
、TimestampMilli
、TimestampMicro
,TimestampNano
types fromstruct
toint64
- Move built-in database field types to new file
types.go
- Fixed
updated_at
field is automatically updated and invalid whengorm
updates data
中文
- 新增
ParseWithLayouts
和ParseWithFormats
方法 - 将
formatFactory
接口更名为FormatFactory
,formatFactory
接口更名为FormatFactory
,formatFactory
接口更名为FormatFactory
, 并添加类型约束 - 将
LayoutType
,FormatType
,TimestampType
结构体GormDataType
方法的返回值更改为time
- 将
DateTime
、Date
、Time
类型从struct
更改为string
- 将
Timestamp
、TimestampMilli
、TimestampMicro
,TimestampNano
类型从struct
更改为int64
- 将内置数据库字段类型移动到新文件
types.go
- 修复
gorm
更新数据时updated_at
字段自动更新无效的 bug