Change Log
v2.7.0 (2026-10-19)
✨ Features
- Add
AddWeekdays,AddWeekday,SubWeekdays,SubWeekdaymethods to skip weekend days when counting working days: moves over days while skipping the weekend days configured on the instance, so deadlines can be counted in working days; the four names mirrorAddDays/AddDay/SubDays/SubDay, and weekend days are read from the instance soSetWeekendDayskeeps working; when all seven days are marked as weekend days, each weekday span is capped to a whole week to prevent infinite loops (by @darakanoit in #366) - Add
IsSameWeekmethod to check whether two dates fall in the same week: completes theIsSame*family (IsSameCentury,IsSameDecade,IsSameYear,IsSameQuarter,IsSameWeek,IsSameMonth,IsSameDay,IsSameHour,IsSameMinute,IsSameSecond); honoursSetWeekStartsAtso two dates that share a week under one setting may not share it under another; the comparison is based on the date the week starts on, correctly handling year-boundary-crossing weeks (by @darakanoit in #368) - Add
IsBirthdaymethod to compare month and day for birthdays: reports whether two dates fall on the same month and day, ignoring the year; without an argument it compares with now; February 29 only matches February 29, so it is never a birthday in a common year, matching PHP Carbon behaviour (by @darakanoit in #364) - Add
Asia/Jakartatimezone constant support (by @mirzaq19 in #374)
🐛 Fixes
- Fix
StartOfSecondandEndOfSecondselecting the wrong occurrence during daylight-saving rollbacks: during a repeated daylight-saving hour,time.Datereconstruction could select the other occurrence of the same local time; now copies the instance and adjusts the existing timestamp's subsecond precision instead, preserving the selected instant, location and configuration (by @mikamikasuki in #377) - Fix
StartOfMinuteandEndOfMinuteselecting the wrong occurrence during daylight-saving rollbacks: same bug as #377 one level up; now copies the instance and subtracts the local seconds, keeping the instant, location and offset (by @dualfroz in #378) - Fix
StartOfHourandEndOfHourselecting the wrong occurrence during daylight-saving rollbacks: preserves the receiver's occurrence when the reconstructed hour boundary has a valid counterpart with the receiver's offset; keeps the existing calendar reconstruction when no such counterpart exists, including Lord Howe's partial-hour transitions (by @dajiaohuang in #382) - Fix
DiffInSecondsignoring the sub-second part and counting inaccurately across second boundaries: subtracting whole-second timestamps ignored the fractional part, so a gap of 0.2s across a second boundary counted as a full second; now adjusts by one when the nanosecond difference has the opposite sign, counting whole seconds elapsed and truncated toward zero (by @youdie006 in #379) - Fix
DiffInDaysandDiffInWeekscomputing incorrect results across DST transitions: dividing elapsed seconds gave wrong results when crossing a DST change; now counts calendar days the wayDiffInMonthscounts months (AddDateplus an adjustment), andDiffInWeeksuses it; only intervals that cross a DST transition change (by @youdie006 in #376) - Fix
DiffInYearsandDiffInMonthsproducing incorrect estimates when comparing dates across different time zones: the first estimate from each date's ownYear()/Month()fields could be off when the two dates are in different locations; now reads the later date in the earlier date's location before taking the year and month fields, matching the frameDiffInDaysuses (by @ybai08 in #384) - Fix
IsSameDecadenot comparing the century:Decade()is the decade within the century, soParse("1995-08-05").IsSameDecade(Parse("2095-08-05"))returned true; now also comparesCentury(), matching the bucketsStartOfDecadeuses (by @youdie006 in #375) - Fix
FromStdTimereturning the wrong lunar date just after midnight when the zone's UTC offset differs from 1900: elapsed time from 1900-01-31 in the time's own zone leaked the two instants' offsets into the day count; now counts the days between the wall-clock dates in UTC, matchingpersian.FromStdTimeandhebrew.FromStdTime(by @youdie006 in #380) - Fix race condition in frozen-clock mode where concurrent
Sleepcalls lost clock advances: concurrentSleepcalls on a frozen clock raced with each other and withNow, losing clock advances; now uses the existing frozen-clock mutex around the check and update (by @yuefdev in #383)
🔧 Dependencies
- Upgrade
github/codeql-actionfromv4.38.1tov4.38.3(by @dependabot[bot] in #372 #381)
v2.6.18 (2026-09-28)
✨ Features
- Add
Kazakhlocalised language support (lang/kk.json): month names, short month names, weekday names and short weekday names are taken verbatim from the Kazakh locale of PHP Carbon, which follows CLDR; relative time phrases follow Kazakh grammar where nouns do not inflect for number after a numeral; seasons and constellations are translated directly using traditional Kazakh names (by @darakanoit in #355)
🐛 Fixes
- Fix possible out-of-bounds access when the
Formatmethod handles a trailing escape character: added boundary checks for escape character handling informat2layoutmethod ofhelper.goto preventpaniccaused by out-of-bounds access (by @gouguoyin in #348) - Fix incorrect weekday names returned by
ToWeekString,ToShortWeekString, andFormatwhen the week starts on a day other than Monday:ToWeekString/ToShortWeekStringindexed the name resource byDayOfWeek() % DaysPerWeek, but the resources are ordered absolutely (Sunday first); now indexes by the absolute weekdayint(StdTime().Weekday()), matching the resource order and mirroring whatFormat("l")already does (by @sneha4175 in #371) - Fix failure to clear the existing value when scanning
NULLfrom a database into a field that already contains a time value: scanning a SQLNULLinto an already populated Carbon value returned success but left the previous date in place; now resets the destination inCarbon.Scanand the layout, format, and timestamp scanner wrappers (by @vitalivo in #360)
⚡ Performance
- Optimize language instance and resource caching and sharing through copy-on-write to reduce memory allocation:
SetLocalecopies the whole cached locale map into everyLanguageinstance, so every Carbon instance allocates a fresh 20-entry map; nowSetLocaleshares the cached map and marks it as shared,SetResourcescopies before its first write, and everything that only reads resources keeps reading the shared map; perNewCarbon(), allocation drops from 1600 B / 13 allocs to 232 B / 4 allocs (by @darakanoit in #350) - Optimize localized resource lookups for months, weekdays, seasons, and constellations to avoid splitting strings on every call: six methods read a "|" separated language resource and call
strings.Spliton every call just to index one element; now a small helper locates the item in place usingstrings.Countandstrings.IndexByte, zero allocations per call;Constellation-61.54%,ToShortWeekString-47.35%,ToWeekString-44.13%,Season-40.65%,ToMonthString-37.66%,ToShortMonthString-35.88% (by @darakanoit in #352) - Share one language instance per locale:
NewCarbon()built a freshLanguagefor every instance; nowdefaultLanguage(locale)caches one ready-to-useLanguageper locale in async.Map; constructing a Carbon goes from 4 allocations to 1 (by @darakanoit in #354) - Optimize lunar date conversion by precomputing tables for days per year and cumulative days: both lunar conversions walked the year table instead of indexing it, costing O(years since 1900); now derives the number of days in each supported year and the running total once at package initialisation; 2020 date to lunar 1009 ns -> 282 ns (-72%), back to gregorian 738 ns -> 23 ns (-97%) (by @darakanoit in #357)
🔧 Dependencies
- Upgrade
github.com/stretchr/testifyfromv1.11.1tov1.12.1(by @dependabot[bot] in #341 #344) - Upgrade
github/codeql-actionfromv4.37.4tov4.38.1(by @dependabot[bot] in #340 #342 #345 #346 #362 #369)
🚀 CI
- Improve the
CItest workflow to run the full test suite and race detection on PRs, and generate and upload coverage only on push: test commands now target all packages via./...instead of only the root package; coverage file generation and Codecov upload are gated topushevents; added a dedicated test step using-raceacross all packages (by @gouguoyin in #361)
v2.6.17 (2026-08-09)
🐛 Fixes
- Fix spelling error in the
Islamicweekday name, changingJumaattoJumat#329 - Fix calculation error in conversion between the
Gregorian calendarand theHebrew calendar#338
🔧 Dependencies
- Upgrade
github/codeql-actionfromv4tov4.37.4#339 - Upgrade
actions/setup-gofromv6tov7#337 - Upgrade
actions/checkoutfromv6tov7#336 - Upgrade
codecov/codecov-actionfromv5tov6#330 - Upgrade
codecov/codecov-actionfromv6tov7#335
📝 Docs
- Unify
READMEdocuments using theNRGstandard template #331 - Clean up redundant advertising external links in
READMEand remove the obsoleteGo Report Cardstatus badge
v2.6.16 (2026-01-28)
🐛 Fixes
- Fix the bug in the parsing of
u,v, andxsymbols in theFormatmethod #328
🔧 Dependencies
- Upgrade
actions/checkoutfromv5tov6
v2.6.15 (2025-11-15)
✨ Features
- Add
HttpLayout,HttpFormatconstants andToHttpStringmethod - Add
Mongolianlocalised language support(lang/mn.json) - Add
Afrikaanslocalised language support(lang/af.json)
🐛 Fixes
- Remove the
Absmethod used in theDiffAbsInDurationmethod of thedifference.gofile, which is only available fromgo1.19 - Fix duplicate
Zondagerror in theweeksfield of theDutchlocalised language file (lang/nl.json)
v2.6.14 (2025-10-28)
✨ Features
- Add
Greeklocalised language support(lang/el.json) - Add
Finnishlocalised language support(lang/fi.json) - Add
Myanmarlocalised language support(lang/my.json)
🐛 Fixes
- Optimize time addition and subtraction series methods in
traveler.gofile to ensure immutability by copying instances to avoid modifying the original instance
v2.6.13 (2025-10-15)
🐛 Fixes
- Add boundary checks for escape character handling in
format2layoutmethod ofhelper.goto preventpaniccaused by out-of-bounds access
⚡ Performance
- Use
sync.OnceinSetLocalemethod oflanguage.goto ensure language files are loaded only once, and usesync.Mapfor thread-safe caching
v2.6.12 (2025-09-16)
🐛 Fixes
- Set
isEmptyflag inUnmarshalJSONmethod oftype_carbon.gofile to indicate empty values - Fix potential race conditions and null pointer dereference issues, improving concurrency safety
⚡ Performance
- Use
sync.Mapto implement high-performance concurrent caching
🔧 Dependencies
- Lower
golangenvironment dependency from1.21to1.18 - Upgrade
testifytesting framework fromv1.10.0tov1.11.1
v2.6.11 (2025-07-18)
✨ Features
- Add
Hebrewcalendar support and add unit tests and benchmark test files
♻️ Refactor & Changes
- Change
Sleepfrom struct method to global method - Refactor
Persiancalendar and add benchmark test files - Refactor
Chinese Lunarcalendar and add benchmark test files - Refactor
Julian/Modified Juliancalendar and add benchmark test files
📝 Docs
- Add overall performance test report file
v2.6.10 (2025-07-07)
✨ Features
- Add
Sleepmethod and relatedunit tests,benchmark tests, andexample file - Add number constants such as
MaxYear,MinYear,MaxMonth,MinMonth,MaxDay,MinDayetc. and replace hard coded with these constants
⚡ Performance
- Optimize
getAbsValuemethod inhelper.goto replace conditional judgments withbitwise operation - Optimize the methods related to time freezing in
frozen.go, reduce lock contention usingatomic operationand optimize memory allocation - Optimize benchmark test files to cover
serialtesting,paralleltesting andconcurrenttesting
♻️ Refactor & Changes
- Change
Japanesetranslation file fromjp.jsontoja.jsonand rename document fromREADME.jp.mdtoREADME.ja.mdto comply with the ISO639-1 standard - Remove deprecated
ParseWithLayoutsmethod and replace withParseByLayoutsmethod - Remove deprecated
ParseWithFormatsmethod and replace withParseByFormatsmethod - Remove deprecated
CleanTestNowmethod and replace withClearTestNowmethod - Remove parsing support for timestamp strings from
ParseByLayoutandParseByFormatmethods, useCreateFromTimestamp,CreateFromTimestampMilli,CreateFromTimestampMicro,CreateFromTimestampNanoto parse timestamp strings
📝 Docs
- Add Korean readme document
README.ko.md
v2.6.9 (2025-06-28)
♻️ Refactor & Changes
- Remove the implementation of the
GormDataTypeinterface forgorm
v2.6.8 (2025-06-12)
🐛 Fixes
- Parsing when layouts or formats is empty, returns a error
♻️ Refactor & Changes
- Rename
DateTimeTypetodateTimeType,DateTimeXXXTypetodateTimeXXXTypeintype_builtin.go - Rename
DateTypetodateType,DateXXXTypetodateXXXTypeintype_builtin.go - Rename
TimeTypetotimeType,TimeXXXTypetotimeXXXTypeintype_builtin.go
🔧 Dependencies
- Upgrade
gorm.io/gormfrom1.21.1to1.30.0intests - Upgrade
gorm.io/driver/mysqlfrom1.5.7to1.6.0intests - Upgrade
gorm.io/driver/postgresfrom1.5.7to1.6.0intests - Upgrade
gorm.io/driver/sqlitefrom1.5.7to1.6.0intests
📝 Docs
- Simplify readme file and migrate overview and example usage to the official doc website
- Add HelloGitHub badge link
v2.6.7 (2025-05-26)
✨ Features
- Change the second parameter of the
Closest/Farthestmethods to an optional parameter - Add
ZeroValue/EpochValuemethods - Add
DataTyperinterface, and enable builtin types to implement theDataTyperinterface
♻️ Refactor & Changes
Stringmethod removes the check for null value carbon- Rename
type_interface.gofile tointerfaces.go
v2.6.6 (2025-05-19)
✨ Features
- Add
curdintegration testing forxorm, currently coveringMySQL/Postgres/SQLite
🐛 Fixes
- Fix bug locale file cannot be found on
Windowsos - Fix bug lose of values of
layout,weekStartsAt,weekendDaysandlangwhen create newCarboninstance - Fix bug
StartOfWeekandEndOfWeekmethods change originalCarboninstance Unexpectedly
🚀 CI
- Add unit testing for the
Windowsos inciaction
v2.6.5 (2025-05-14)
✨ Features
SetLanguagemethod ofCarbonstruct add check for invalidLanguagestructParsemethod ofCarbonstruct add support forPostgres/SQLitetime format stringParse/ParseByLayout/ParseByFormatmethods ofCarbonstruct change the return value fromniltoemptycarbon when parsing anemptystringCarbonstruct addIsEmptymethod to determine if it is anemptycarbonCarbonstruct addClearTestNowmethod to replaceCleanTestNow,CleanTestNowwill be removed in the futureCarbonstruct addParseByLayoutsmethod to replaceParseWithLayouts,ParseWithLayoutswill be removed in the futureCarbonstruct addParseByFormatsmethod to replaceParseWithFormats,ParseWithFormatswill be removed in the futureSetResourcesmethod ofLanguagestruct add check invalid resources- Add
curdintegration testing forgorm, currently coveringMySQL/Postgres/SQLite
♻️ Refactor & Changes
Carbonstruct removeGormDataTypemethod and changeValue/MarshalJSONmethods frompointerreceiver tovaluereceiverLayoutType[T]struct removeGormDataTypemethod and changeValue/MarshalJSONmethods frompointerreceiver tovaluereceiverFormatType[T]struct removeGormDataTypemethod and changeValue/MarshalJSONmethods frompointerreceiver tovaluereceiverTimestampType[T]struct removeGormDataTypemethod and changeValue/MarshalJSONmethods frompointerreceiver tovaluereceiver- Replace
github.com/stretchr/testify/assertwithgithub.com/stretchr/testify/suitefor unit testing
🔧 Dependencies
- Upgrade
goversion from1.18to1.21
v2.6.4 (2025-04-28)
✨ Features
- Add
Copymethod forLanguagestruct - Add
carbon.Timestamptype alias andcarbon.NewTimestampmethod - Add
carbon.TimestampMillitype alias andcarbon.NewTimestampMillimethod - Add
carbon.TimestampMicrotype alias andcarbon.NewTimestampMicromethod - Add
carbon.TimestampNanotype alias andcarbon.NewTimestampNanomethod - Add
carbon.DateTimetype alias andcarbon.NewDateTimemethod - Add
carbon.DateTimeMicrotype alias andcarbon.NewDateTimeMicromethod - Add
carbon.DateTimeMillitype alias andcarbon.NewDateTimeMillimethod - Add
carbon.DateTimeNanotype alias andcarbon.NewDateTimeNanomethod - Add
carbon.Datetype alias andcarbon.NewDatemethod - Add
carbon.DateMillitype alias andcarbon.NewDateMillimethod - Add
carbon.DateMicrotype alias andcarbon.NewDateMicromethod - Add
carbon.DateNanotype alias andcarbon.NewDateNanomethod - Add
carbon.Timetype alias andcarbon.NewTimemethod - Add
carbon.TimeMillitype alias andcarbon.NewTimeMillimethod - Add
carbon.TimeMicrotype alias andcarbon.NewTimeMicromethod - Add
carbon.TimeNanotype alias andcarbon.NewTimeNanomethod
🐛 Fixes
- Fix panic when database field type was
nil
⚡ Performance
- Add
b.ResetTimer()in benchmark test files
♻️ Refactor & Changes
- Split
database_types.gointotype_carbon.go,type_layout.go,type_format.go,type_timestamp.go - Rename
LayoutFactoryinterface toLayoutTyperandSetLayoutmethod toLayout - Rename
FormatFactoryinterface toFormatTyperandSetFormatmethod toFormat - Rename
TimestampFactoryinterface toTimestampTyperandSetPrecisionmethod toPrecision
v2.6.3 (2025-04-21)
✨ Features
- Add
IsEpochmethod to report whether is a unix epoch time(1970-01-01 00:00:00 +0000 UTC). - Add
WeekEndsAtmethod to get end day of the week. - Add
SetWeekendDaysmethod to set weekend days of the week. - Add
DefaultWeekStartsAtglobal variable to store weekend days of the week.
🐛 Fixes
- Fix bug with the same results in different countries using
IsWeekendandIsWeekdaymethods. - Fix bug
carbon.Parse("").StdTime()cause a nil pointer panic. #294
⚡ Performance
- Add benchmark test files
xxx_bench_test.go
♻️ Refactor & Changes
- Change errors from
privatemethod topublicmethod. - Change the default start date of the week from
SundaytoMonday - Change the year of
MinValuefrom-9998to1 - Change
weeksPerLongYearconstant toWeeksPerLongYear
v2.6.2 (2025-04-08)
✨ Features
- Add format symbol
oto get time zone offset - Add
TimestampLayout,TimestampMilliLayout,TimestampMicroLayoutandTimestampNanoLayoutconstants - Add
TimestampFormat,TimestampMilliFormat,TimestampMicroFormatandTimestampNanoFormatconstants - Add
DateTimeMilli,DateTimeMicro,DateTimeNanofield types - Add
DateMilli、DateMicro、DateNanofield types - Add
TimeMilli、TimeMicro、TimeNanofield types - Add
MaxDuration,MinDurationmethods
🐛 Fixes
- Fix bug of incorrect judgment of
IsLeapMonthin lunar calendar - Fix bug of
AtomFormatandAtomLayoutreturn inconsistent value - Fix bug of
RFC3339FormatandRFC3339Layoutreturn inconsistent value - Fix missing timezone bug in
IsDSTmethod - Fix missing timezone bug
StartOfXXX,EndOfXXXmethods - Fix missing timezone bug when converting other calendars to
Gregoriancalendar
♻️ Refactor & Changes
- Remove
hour,minute,secondparameter inCreateFromLunar,CreateFromPersianmethods - Change some format symbol definitions involves symbols such as
U,V,X,S,TZ,u,v,x,z time.Localis not updated when setting global time zone
v2.6.1 (2025-03-27)
✨ Features
- Add
ParseWithLayoutsandParseWithFormatsmethods
🐛 Fixes
- Fixed
updated_atfield is automatically updated and invalid whengormupdates data
♻️ Refactor & Changes
- Rename
formatFactoryinterface toFormatFactory,layoutFactoryinterface toLayoutFactory,timestampFactoryinterface toTimestampFactory, and add type constraints - Change the return value of the
GormDataTypemethod of theLayoutType,FormatType,TimestampTypestructtotime - Change
DateTime,Date,Timetypes fromstructtostring - Change
Timestamp、TimestampMilli、TimestampMicro,TimestampNanotypes fromstructtoint64 - Move built-in database field types to new file
types.go
v2.6.0 (2025-03-25)
✨ Features
- Add
ZoneNamemethod to get the time zone name - Add
HasErrormethod to check if there is an error - Add
IsNilmethod to check if it isnil - Add
Copymethod to deep copycarbon - Add
WeekStartsAtmethod to get start day of the week - Add example file
xxx_example.go - Add a new
constant.gofile and migrate constants from thecarbon.gofile to this file
♻️ Refactor & Changes
golangminimum version dependency upgraded to1.18carbon,julian,lunar,persianchanged from value passing to pointer passing- Change default global timezone from
LocaltoUTC - Rename
Offsetmethod toZoneOffsetmethod - Rename
IsSetTestNowmethod toIsTestNowmethod - Rename
UnSetTestNowmethod toCleanTestNowmethod - Remove
Locationmethod, replaced byTimezonemethod - Change the judgment logic of
IsValidandIsInvalidmethods,zero timeis no longer considered invalid time - Update
time.Localwhen setting the global default timezone - Refactor
database.goand removecarbon.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.TimestampNanofield types, use generic fields instead to implement custom output format whenMarshalJSON/UnmarshalJSON
Refer to releases for change logs of earlier versions