Repository navigation
Releases
Releases · dromara/carbon
v2.7.1
English
✨ Features
- Add Bengali (
bn) language support: adds localized month and weekday names, relative time expressions, seasons, and constellations (by @Goldloli in #390).
🐛 Fixes
- Fix a panic when converting dates outside the supported lunar calendar range: dates outside
1900-01-31through2101-01-28now produce an invalidLunarvalue with an error instead of causing an index-out-of-range panic (by @ybai08 in #389). - Fix the start date of Sagittarius:
IsSagittariusnow starts on November 23, so November 22 is no longer classified as both Scorpio and Sagittarius (by @ChandraChaan in #391). - Fix the Persian name for Sunday: corrects the value returned by
ToWeekString(FaLocale)(by @ChandraChaan in #392). - Fix
AddDurationandSubDurationmodifying the receiver on a parse error: the returned value carries the error while the original instance remains unchanged (by @simpleqt in #393).
🔧 Dependencies
- Upgrade
actions/checkoutfromv4tov7(by @dependabot[bot] in #385). - Upgrade
github/codeql-actionfromv4.38.3tov4.39.1(by @dependabot[bot] in #386 and #388). - Upgrade
actions/setup-gofromv5tov7(by @dependabot[bot] in #387). - Upgrade the
github.com/stretchr/testifytest dependency tov1.12.1.
中文
✨ 新功能
🐛 修复
- 修复超出农历支持范围时发生 panic 的问题:公历日期超出
1900-01-31至2101-01-28时,返回携带错误的无效Lunar值,避免数组越界(by @ybai08 in #389)。 - 修复射手座起始日期错误的问题:
IsSagittarius从 11 月 23 日开始判定,避免将 11 月 22 日同时判定为天蝎座和射手座(by @ChandraChaan in #391)。 - 修复波斯语星期日名称拼写错误的问题:更正
ToWeekString(FaLocale)返回的星期日名称(by @ChandraChaan in #392)。 - 修复
AddDuration和SubDuration解析失败时修改原实例的问题:错误保留在返回值中,原实例保持不变(by @simpleqt in #393)。
🔧 依赖升级
- 将
actions/checkout从v4升级到v7(by @dependabot[bot] in #385)。 - 将
github/codeql-action从v4.38.3升级到v4.39.1(by @dependabot[bot] in #386 和 #388)。 - 将
actions/setup-go从v5升级到v7(by @dependabot[bot] in #387)。 - 将测试依赖
github.com/stretchr/testify升级到v1.12.1。
v2.7.0
English
✨ 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)
中文
✨ 新功能
- 新增
AddWeekdays、AddWeekday、SubWeekdays、SubWeekday方法,支持跳过周末日进行工作日计算:按实例配置的周末日跳过非工作日进行日期推移,方便按工作日计算截止日期;四个方法命名与AddDays/AddDay/SubDays/SubDay保持一致,周末日从实例读取因此SetWeekendDays仍生效;当七天全部被标记为周末日时,每个工作日跨度被限制为整周以防止死循环(by @darakanoit in #366) - 新增
IsSameWeek方法,判断两个日期是否在同一周:补全IsSame*家族(IsSameCentury、IsSameDecade、IsSameYear、IsSameQuarter、IsSameWeek、IsSameMonth、IsSameDay、IsSameHour、IsSameMinute、IsSameSecond);尊重SetWeekStartsAt设置,因此同一组日期在不同设置下可能不属于同一周;比较基于周起始日期,正确处理跨年份的边界周(by @darakanoit in #368) - 新增
IsBirthday方法,比较月日判断是否生日:判断两个日期是否落在同一月同日,忽略年份;无参数时与当前时间比较;2月29日仅匹配2月29日,平年永远不会是生日,与 PHP Carbon 行为一致(by @darakanoit in #364) - 新增
Asia/Jakarta时区常量支持(by @mirzaq19 in #374)
🐛 修复
- 修复夏令时回退期间
StartOfSecond和EndOfSecond方法选择错误时间出现的问题:在重复的夏令时小时内,time.Date重建可能选择同一本地时间的另一次出现;现在改为复制实例并调整现有时间戳的亚秒精度,保留选中的时刻、位置和配置(by @mikamikasuki in #377) - 修复夏令时回退期间
StartOfMinute和EndOfMinute方法选择错误时间出现的问题:与 #377 同一类 bug,只是上升了一级;现在复制实例并减去本地秒数,保留时刻、位置和偏移(by @dualfroz in #378) - 修复夏令时回退期间
StartOfHour和EndOfHour方法选择错误时间出现的问题:当重建的小时边界存在与接收器偏移一致的有效对应出现时,保留接收器的出现;不存在对应出现时(如 Lord Howe 的部分小时间隔回退)保持现有日历重建行为(by @dajiaohuang in #382) - 修复
DiffInSeconds方法忽略亚秒部分导致跨秒边界计时不准确的问题:减去整秒时间戳时忽略了小数部分,导致跨越秒边界的 0.2 秒间隙被计为整秒;现在当纳秒差符号相反时调整 ±1,按已流逝的整秒计数并朝零截断(by @youdie006 in #379) - 修复
DiffInDays和DiffInWeeks方法跨越夏令时转换时计算错误的问题:除以流逝秒数在跨越夏令时转换时给出错误结果;现在改为按日历日计数(与DiffInMonths按月计数方式一致,AddDate加调整),DiffInWeeks基于它计算;仅跨越夏令时转换的区间结果会变化(by @youdie006 in #376) - 修复
DiffInYears和DiffInMonths方法在不同时区之间比较时估算错误的问题:从各自日期的Year()/Month()字段进行首次估算时,两个日期处于不同位置可能导致偏差;现在先以较早日期所在位置读取较晚日期,再取年月字段,与DiffInDays使用的框架一致(by @ybai08 in #384) - 修复
IsSameDecade方法未比较世纪导致跨世纪日期误判的问题:Decade()是世纪内的十年,因此Parse("1995-08-05").IsSameDecade(Parse("2095-08-05"))曾返回 true;现在也比较Century(),与StartOfDecade使用的分桶一致(by @youdie006 in #375) - 修复
FromStdTime方法在凌晨时刻因 UTC 偏移差异返回错误农历日期的问题:以时间所在时区计算从 1900-01-31 起流逝的时间,两个时刻的偏移会泄漏到日计数中;现在改为在 UTC 中计算挂钟日期之间的天数,与persian.FromStdTime和hebrew.FromStdTime一致(by @youdie006 in #380) - 修复冻结时钟模式下并发调用
Sleep方法导致时钟推进丢失的竞态问题:冻结时钟上的并发Sleep调用彼此以及与Now发生竞态,导致时钟推进丢失;现在使用现有的冻结时钟互斥锁包裹检查和更新(by @yuefdev in #383)
🔧 依赖升级
- 将
github/codeql-action从v4.38.1升级到v4.38.3(by @dependabot[bot] in #372 #381)
v2.6.18
English
✨ 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)
中文
✨ 新功能
- 新增对
哈萨克语的本地化语言支持(lang/kk.json):月份名称、短月份名称、星期名称和短星期名称取自 PHP Carbon 的哈萨克语本地化文件(遵循 CLDR);相对时间短语遵循哈萨克语语法,名词在数字后不变格;季节和星座使用传统哈萨克名称直译(by @darakanoit in #355)
🐛 修复
- 修复
Format方法处理末尾转义字符时可能发生越界访问的 bug:在helper.go的format2layout方法中为转义字符处理添加边界检查,防止越界访问导致的panic(by @gouguoyin in #348) - 修复设置非周一为一周开始日期时,
ToWeekString、ToShortWeekString和Format方法返回星期名称错误的 bug:ToWeekString/ToShortWeekString曾通过DayOfWeek() % DaysPerWeek索引名称资源,但资源按绝对顺序(周日优先)排列;现在改用int(StdTime().Weekday())按绝对星期索引,与Format("l")行为一致(by @sneha4175 in #371) - 修复向已有时间值的数据库字段扫描
NULL时未清空原值的 bug:向已包含时间值的 Carbon 扫描 SQLNULL时返回成功但保留原日期;现在在Carbon.Scan及布局、格式和时间戳扫描器包装器中重置目标值(by @vitalivo in #360)
⚡ 性能优化
- 优化语言实例和语言资源的缓存与共享机制,通过写时复制减少内存分配:
SetLocale此前将完整的缓存语言映射复制到每个Language实例,导致每个 Carbon 实例分配全新的 20 项映射;现在SetLocale共享缓存映射并标记为共享,SetResources在首次写入前复制,只读资源的方法继续使用共享映射;每个NewCarbon()的分配从 1600 B / 13 次降至 232 B / 4 次(by @darakanoit in #350) - 优化月份、星期、季节和星座本地化资源查询,避免每次调用分割字符串:六个方法每次调用都读取 "|" 分隔的语言资源并使用
strings.Split分割,仅为了索引一个元素;现在使用小型辅助函数通过strings.Count和strings.IndexByte原地定位元素,每次调用零分配;Constellation-61.54%,ToShortWeekString-47.35%,ToWeekString-44.13%,Season-40.65%,ToMonthString-37.66%,ToShortMonthString-35.88%(by @darakanoit in #352) - 每个 locale 共享一个语言实例:
NewCarbon()此前为每个实例构建全新的Language;现在defaultLanguage(locale)在sync.Map中缓存每个 locale 一个即用型Language;构造 Carbon 的分配从 4 次降至 1 次(by @darakanoit in #354) - 优化农历日期转换,预计算年度天数和累计天数表:农历转换此前遍历年份表而非索引,时间复杂度为 O(1900年以来的年数);现在在每个支持的年份和累计总数在包初始化时推导一次;2020 日期转农历 1009 ns -> 282 ns(-72%),转回公历 738 ns -> 23 ns(-97%)(by @darakanoit in #357)
🔧 依赖升级
- 将
github.com/stretchr/testify从v1.11.1升级到v1.12.1(by @dependabot[bot] in #341 #344) - 将
github/codeql-action从v4.37.4升级到v4.38.1(by @dependabot[bot] in #340 #342 #345 #346 #362 #369)
🚀 CI
- 完善
CI测试流程,在PR上运行完整测试和竞态检测,并仅在push时生成和上传覆盖率:测试命令现在通过./...覆盖所有包,而非仅根包;覆盖率文件生成和 Codecov 上传限制为push事件;新增使用-race的全包竞态检测步骤(by @gouguoyin in #361)
What's Changed
- build(deps): bump github/codeql-action from 4.37.4 to 4.37.6 by @dependabot[bot] in #340
- build(deps): bump github.com/stretchr/testify from 1.11.1 to 1.12.0 by @dependabot[bot] in #341
- build(deps): bump github/codeql-action from 4.37.6 to 4.37.7 by @dependabot[bot] in #342
- build(deps): bump github.com/stretchr/testify from 1.12.0 to 1.12.1 by @dependabot[bot] in #344
- build(deps): bump github/codeql-action from 4.37.7 to 4.37.8 by @dependabot[bot] in #345
- build(deps): bump github/codeql-action from 4.37.8 to 4.37.9 by @dependabot[bot] in #346
- Fix possible out-of-bounds access when formatting time by @gouguoyin in #348
- perf(language): Copy locale resources on write instead of on every SetLocale by @darakanoit in #350
- perf(i18n): Look up language resources without splitting them on every call by @darakanoit in [#352](#3...
v2.6.17
Full Changelog: v2.6.16...v2.6.17
English
🐛 Fixes
- Fix spelling error of the Friday name in the
Indonesianlocale (lang/id.json): the week-name resource spelled Friday asJumaat; now changed toJumat, the correct form in the official Indonesian dictionary (KBBI) (by @nmfzone in #329) - Fix systematically wrong conversion between the
Gregorian calendarand theHebrew calendar:calendar/hebrewreturned wrong dates in both directions —NewHebrew(5784, 7, 1).ToGregorian()gave 2023-09-01 instead of 2023-09-16, andFromStdTime(2025-10-03)gave 5786-07-10 instead of 5786-07-11; the shared JDN conversion core reconstructed a Julian-calendar date (missing the Gregorian-reform correction, so modern dates came out ~13 days early), derived Rosh Hashanah from a routine that produced impossible year lengths, shortened Kislev in the wrong year type, and letjdn2hebrewadvance the month a day early; it is now rebuilt on the standard Dershowitz–Reingold arithmetic over a single integer Julian-Day axis, matching the reference implementations on all 517,914 dates from 1583 to 3000 in both directions (by @binggao1230 in #338)
📄 Documentation
- Migrate the four
READMEfiles to a singleNRGtemplate:README.md,README.cn.md,README.ja.mdandREADME.ko.mdwere maintained side by side, so every change meant editing the same paragraph in four places; they are now generated from one source of truth,README.src.md, whose lines are tagged with ``, and.github/workflows/nrg.ymlregenerates and auto-commits on push tomasterwhile running a drift check on PRs; the generated files are byte-identical to the previous ones apart from a 2-line auto-generated header (by @andriishin in #331) - Remove the obsolete
Go Report Cardbadge and clean up redundant advertising links in theREADME(by @gouguoyin ina65ddec)
🔧 Dependencies
- Upgrade
github/codeql-actionfromv4tov4.37.4(by @dependabot[bot] in #339)
🚀 CI
- Upgrade
actions/checkoutfromv4tov7(by @dependabot[bot] in #332 #336) - Upgrade
actions/setup-gofromv6tov7(by @dependabot[bot] in #337) - Upgrade
codecov/codecov-actionfromv5tov7(by @dependabot[bot] in #330 #335)
中文
🐛 修复
- 修复
印度尼西亚语本地化文件中星期五名称拼写错误的 bug(lang/id.json):星期名称资源曾将星期五拼写为Jumaat;现已改为Jumat,这是印尼语官方词典(KBBI)中的正确写法(by @nmfzone in #329) - 修复
公历与希伯来历之间换算结果系统性错误的 bug:calendar/hebrew双向换算均返回错误日期 ——NewHebrew(5784, 7, 1).ToGregorian()返回 2023-09-01 而非 2023-09-16,FromStdTime(2025-10-03)返回 5786-07-10 而非 5786-07-11;其共享的儒略日换算核心重建了儒略历日期(缺少格里高利历改历修正,导致现代日期提前约 13 天)、用会产生不可能年长(如 5785→5786 的 356 天)的算法推导岁首、在错误的年份类型上缩短基斯流月、并让jdn2hebrew提前一天进位月份;现在核心已按标准 Dershowitz–Reingold 算法重建于单一整数儒略日轴上,在 1583 至 3000 年间的全部 517,914 个日期上双向均与参考实现一致(by @binggao1230 in #338)
📄 文档
- 将四个
README文档迁移为单一的NRG模板:README.md、README.cn.md、README.ja.md和README.ko.md此前是并列手工维护的,每次修改都要在四处编辑同一段落;现在统一由唯一数据源README.src.md生成,其每一行都用 `` 标记所属语言,.github/workflows/nrg.yml在推送master时自动重新生成并提交,在PR上执行漂移检查;生成结果除 2 行自动生成的文件头外与原有文件完全一致(by @andriishin in #331) - 移除
README中已废弃的Go Report Card状态徽章,并清理冗余广告外链(by @gouguoyin ina65ddec)
🔧 依赖升级
- 将
github/codeql-action从v4升级到v4.37.4(by @dependabot[bot] in #339)
🚀 CI
- 将
actions/checkout从v4升级到v7(by @dependabot[bot] in #332 #336) - 将
actions/setup-go从v6升级到v7(by @dependabot[bot] in #337) - 将
codecov/codecov-action从v5升级到v7(by @dependabot[bot] in #330 #335)
What's Changed
- Should be Jumat not Jumaat by @nmfzone in #329
- build(deps): bump codecov/codecov-action from 5 to 6 by @dependabot[bot] in #330
- docs: migrate 4 README files to a single NRG template by @andriishin in #331
- build(deps): bump actions/checkout from 4 to 6 by @dependabot[bot] in #332
- build(deps): bump codecov/codecov-action from 6 to 7 by @dependabot[bot] in #335
- build(deps): bump actions/checkout from 6 to 7 by @dependabot[bot] in #336
- build(deps): bump actions/setup-go from 6 to 7 by @dependabot[bot] in #337
- Fix systematically wrong Gregorian and Hebrew calendar conversion by @binggao1230 in #338
- build(deps): bump github/codeql-action from 4 to 4.37.4 by @dependabot[bot] in #339
v2.6.16
v2.6.15
English
- Remove the
Absmethod used in theDiffAbsInDurationmethod of thedifference.gofile, which is only available sincego1.19 - Fix duplicate
Zondagerror in theweeksfield of theDutchlocalised language file(lang/nl.json) - Add
HttpLayout,HttpFormatconstants andToHttpStringmethod - Add
Mongolianlocalised language support(lang/mn.json) - Add
Afrikaanslocalised language support(lang/af.json)
中文
- 移除
difference.go文件的DiffAbsInDuration方法里使用的从go1.19才有的Abs方法 - 修复
荷兰语本地化语言文件(lang/nl.json)里weeks字段里重复的Zondag错误 - 增加
HttpLayout,HttpFormat常量以及ToHttpString方法 - 增加对
蒙古语的本地化语言支持(lang/mn.json) - 增加对
南非语的本地化语言支持(lang/af.json)
Full Changelog: v2.6.14...v2.6.15
v2.6.14
English
- Refactor time addition and subtraction series methods in
traveler.gofile to ensure immutability by copying instances to avoid modifying the original instance - Add
Greeklocalised language support - Add
Finnishlocalised language support - Add
Myanmarlocalised language support
中文
- 重构
traveler.go文件里时间增减系列方法通过复制实例来保证不可变性,以避免修改原始实例 - 增加对
希腊语的本地化语言支持 - 增加对
芬兰语的本地化语言支持 - 增加对
缅甸语的本地化语言支持
Full Changelog: v2.6.13...v2.6.14
v2.6.13
English
- Use
sync.OnceinSetLocalemethod oflanguage.goto ensure language files are loaded only once, and usesync.Mapfor thread-safe caching #319 - Add boundary checks for escape character handling in
format2layoutmethod ofhelper.goto preventpaniccaused by out-of-bounds access
中文
- 在
language.go的SetLocale方法中使用sync.Once确保语言文件只加载一次,使用sync.Map进行线程安全的缓存 - 在
helper.go的format2layout方法中为转义字符处理添加边界检查, 防止越界访问导致的panic
Full Changelog: v2.6.12...v2.6.13
v2.6.12
English
- Lower
golangenvironment dependency from1.21to1.18 - Upgrade
testifytesting framework fromv1.10.0tov1.11.1 - Set
isEmptyflag inUnmarshalJSONmethod oftype_carbon.gofile to indicate empty values - Use
sync.Mapto implement high-performance concurrent caching - Fix potential race conditions and null pointer dereference issues, improving concurrency safety
中文
- 将
golang环境依赖从1.21降低到1.18 - 将
testify测试框架从v1.10.0升级到v1.11.1 - 在
type_carbon.go文件UnmarshalJSON方法中设置isEmpty标志以表示空值 - 使用
sync.Map实现高性能并发缓存 - 修复潜在的竞态条件和空指针解引用问题,提高并发安全性
Full Changelog: v2.6.11...v2.6.12
v2.6.11
English
- 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 - Add
Hebrewcalendar support and add unit tests and benchmark test files - Add overall performance test report file
中文
- 将
Sleep由结构体方法更改成全局方法 - 重构
波斯历并添加基准测试文件 - 重构
中国农历并添加基准测试文件 - 重构
儒略日/简化儒略日并添加基准测试文件 - 新增
希伯来历支持并添加单元测试和基准测试文件 - 新增整体性能测试报告文件
Full Changelog: v2.6.10...v2.6.11