Skip to content

Releases: dromara/carbon

v2.6.2-rc1

31 Mar 02:11

Choose a tag to compare

English
  • Remove hour, Minute,second parameter in CreateFromLunar,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 and AtomLayout return inconsistent value
  • Fix bug of RFC3339Format and RFC3339Layout 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 and TimestampNanoLayout constants
  • Add TimestampFormat, TimestampMilliFormat, TimestampMicroFormat and TimestampNanoFormat constants
  • Add DateTimeMilli, DateTimeMicro, DateTimeNano field types
  • Add DateMilliDateMicroDateNano field types
  • Add TimeMilliTimeMicroTimeNano field types
中文
  • CreateFromLunar, CreateFromPersian 方法去掉 hour, minute, second 参数
  • 更改部分格式符号定义,涉及到的符号有 U, V, X,S,T Z,u,v,x,z
  • 修复农历中 IsLeapMonth 判断错误的 bug
  • 修复 AtomFormatAtomLayout 格式返回值不一致的 bug
  • 修复 RFC3339FormatRFC3339Layout 格式返回值不一致的 bug
  • 设置全局默认时区时不再同步更新 time.Local
  • 新增格式符号o 来获取时区偏移量
  • 新增 TimestampLayoutTimestampMilliLayoutTimestampMicroLayoutTimestampNanoLayout 常量
  • 新增 TimestampFormatTimestampMilliFormatTimestampMicroFormatTimestampNanoFormat 常量
  • 新增 DateTimeMilliDateTimeMicroDateTimeNano 字段类型
  • 新增 DateMilliDateMicroDateNano 字段类型
  • 新增 TimeMilliTimeMicroTimeNano 字段类型

v2.6.1

27 Mar 01:58

Choose a tag to compare

English
  • Add ParseWithLayouts and ParseWithFormats methods
  • Rename formatFactory interface to FormatFactory, formatFactory interface to FormatFactory, formatFactory interface to FormatFactory, and add type constraints
  • Change the return value of the GormDataType method of the LayoutType, FormatType, TimestampType struct to time
  • Change DateTime, Date, Time types from struct to string
  • Change TimestampTimestampMilliTimestampMicro,TimestampNano types from struct to int64
  • Move built-in database field types to new file types.go
  • Fixed updated_at field is automatically updated and invalid when gorm updates data
中文
  • 新增 ParseWithLayoutsParseWithFormats 方法
  • formatFactory 接口更名为 FormatFactory, formatFactory 接口更名为 FormatFactory, formatFactory 接口更名为 FormatFactory, 并添加类型约束
  • LayoutType ,FormatType, TimestampType 结构体GormDataType 方法的返回值更改为 time
  • DateTimeDateTime 类型从 struct 更改为 string
  • TimestampTimestampMilliTimestampMicro,TimestampNano 类型从 struct 更改为 int64
  • 将内置数据库字段类型移动到新文件 types.go
  • 修复 gorm 更新数据时 updated_at 字段自动更新无效的 bug

v2.6.0

25 Mar 01:40

Choose a tag to compare

⚠️ This is a break update version, please upgrade with caution, but it is strongly recommended to upgrade 这是一个破坏性更新版本,请慎重升级,但是强烈建议升级

English
  • golang minimum version dependency upgraded to 1.18
  • carbon, julian, lunar, persian changed from value passing to pointer passing
  • Add ZoneName method to get the time zone name
  • Add HasError method to check if there is an error
  • Add IsNil method to check if it is nil
  • Add Copy method to deep copy carbon
  • Add WeekStartsAt method to get start day of the week
  • Add example file xxx_example.go
  • Add a new constant.go file and migrate constants from the carbon.go file to this file
  • Change default global timezone from Local to UTC
  • Rename Offset method to ZoneOffset method
  • Rename IsSetTestNow method to IsTestNow method
  • Rename UnSetTestNow method to CleanTestNow method
  • Remove Location method, replaced by Timezone method
  • Change the judgment logic of IsValid and IsInvalid methods, zero time is no longer considered invalid time
  • Update time.Local when setting the global default timezone
  • Refactor database.go and remove 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 field types, use generic fields instead to implement custom output format when MarshalJSON/UnmarshalJSON
中文
  • golang 最低版本依赖升级到 1.18
  • carbon, julian, lunar, persian 从值传递改成指针传递
  • 新增 ZoneName 方法获取时区名称
  • 新增 HasError 方法判断是否有错误
  • 新增 IsNil 方法判断是否是 nil
  • 新增 Copy 方法对 carbon 进行深度复制
  • 新增 WeekStartsAt 方法获取周起始日期
  • 新增示例文件 xxx_example.go
  • 新增constant.go 文件,将常量从 carbon.go 文件迁移到此文件
  • 默认全局时区从 Local 更改为 UTC
  • Offset 方法更名为 ZoneOffset
  • IsSetTestNow 方法更名为 IsTestNow
  • UnSetTestNow 方法更名为 CleanTestNow
  • 移除 Location 方法,由 Timezone 方法替代
  • 更改 IsValidIsInvalid 方法判断逻辑,zero time 不再视为无效时间
  • 设置全局默认时区时同步更新 time.Local
  • 重构 database.go,移除 carbon.DateTimecarbon. DateTimeMilli carbon.DateTimeMicrocarbon.DateTimeNanocarbon. Datecarbon.DateMillicarbon.DateMicrocarbon.DateNanocarbon.Timecarbon.TimeMillicarbon.TimeMicrocarbon.TimeNanocarbon.Timestampcarbon.TimestampMilli carbon.TimestampMicrocarbon.TimestampNano 字段类型, 使用泛型字段替代以实现 MarshalJSON/UnmarshalJSON 时自定义输出格式

v2.5.4

05 Mar 06:39

Choose a tag to compare

  • add Norwegian language support, translated by bendikrb #281
  • add optional parameter time.Time in NewCarbon method
  • move all constant from carbon.go to a new constant.go

v2.5.3

26 Feb 11:31

Choose a tag to compare

  • add CurrentLayout method #279
  • fix parsing errors caused by empty strings #271 #275
  • unify receiver type #262

v2.5.2

03 Dec 02:40

Choose a tag to compare

What's Changed

  • Fix Time, TimeMilli, TimeMicro, TimeNano type fields cannot be parsed when unmarshalJSON
  • Remove deprecated method ToStdTime
  • Add MaxValue, MinValue, IsValid methods for Gregorian calendar
  • Add MaxValue, MinValue, IsValid methods for Lunar calendar
  • Add MaxValue, MinValue, ToShortMonthString, ToShortWeekString methods for Persian calendar
  • Add optional parameter local, optional value en/fa for Persian calendar ToMonthString, ToWeekString methods, default is en

Full Changelog: v2.5.1...v2.5.2

v2.5.1

29 Nov 07:55

Choose a tag to compare

What's Changed

  • Add MaxValue,MinValue methods
  • Add reference url
  • Optimize IsValid method base MinValue, MinValue
  • Time, TimeMilli, TimeMicro, TimeNano structs set year, month, day when UnmarshalJSON
  • Fix minor grammar and notation corrections by @You-saku in #260
  • Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 by @dependabot in #261

Full Changelog: v2.5.0...v2.5.1

v2.5.0

25 Nov 09:30

Choose a tag to compare

What's Changed

  • Change repository url from github.com/golang-module/carbon to github.com/dromara/carbon
  • Add hungarian translation #39 by @kenlas in #252
  • Add support for string and []byte types when parsing database data in Scan method #251
  • Retranslate README.jp by @You-saku in #259
  • Fix DiffInMonths() method bug #255
  • Fix Japanese translation by @nkmr-jp in #254
  • Replace Lock() with RLock(),Unlock() with RUnlock() to optimize performance by @ritbrz in #253
  • Replace ToDateTimeStruct() with NewDateTime(),ToDateTimeMilliStruct() with NewDateTimeMilli(),ToDateTimeMicroStruct() with NewDateTimeMicro(),ToDateTimeMilliNanoStruct() with NewDateTimeNano()
  • Replace ToDateStruct() with NewDate(),ToDateMilliStruct() with NewDateMilli(),ToDateMicroStruct() with NewDateMicro(),ToDateNanoStruct() with NewDateNano()
  • Replace ToTimeStruct() with NewTime(),ToTimeMilliStruct() with NewTimeMilli(),ToTimeMicroStruct() with NewTimeMicro(),ToTimeNano()Struct with NewTimeNano()
  • DateTime, DateTimeXXX,Date,DateXXX, Time,TimeXXX structures implement Scan,Value,MarshalJSON,UnmarshalJSON interfaces
  • Bump codecov/codecov-action from 4 to 5 by @dependabot in #256
  • Unified use of global default timezone defaultTimezone when UnmarshalJSON

New Contributors

Full Changelog: v2.4.1...v2.5.0

v2.4.1

15 Oct 02:08

Choose a tag to compare

  • Fix issue #240
  • Optimize StdTime method when time is zero
  • Move GormDataType from encoding.go to database.go

v2.4.0

11 Oct 16:09

Choose a tag to compare

  • Fixed Farsi language translation bug #247
  • Fixed gregorian calendar to lunar calendar bug #246
  • Updated the minimum version of Go required to 1.17 #245
  • Optimized ParseByLayout and getLocationByTimezone methods when the timezone is empty
  • Optimized the scenario of JSON unmarsha when the value of the JSON string is empty or null
  • Removed Tag struct and related methods
  • Added Arabic language support #250