You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
English
✨ Features
Add AddWeekdays, AddWeekday, SubWeekdays, SubWeekday methods 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 mirror AddDays / AddDay / SubDays / SubDay, and weekend days are read from the instance so SetWeekendDays keeps 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 IsSameWeek method to check whether two dates fall in the same week: completes the IsSame* family (IsSameCentury, IsSameDecade, IsSameYear, IsSameQuarter, IsSameWeek, IsSameMonth, IsSameDay, IsSameHour, IsSameMinute, IsSameSecond); honours SetWeekStartsAt so 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 IsBirthday method 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/Jakarta timezone constant support (by @mirzaq19 in #374)
🐛 Fixes
Fix StartOfSecond and EndOfSecond selecting the wrong occurrence during daylight-saving rollbacks: during a repeated daylight-saving hour, time.Date reconstruction 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 StartOfMinute and EndOfMinute selecting 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 StartOfHour and EndOfHour selecting 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 DiffInSeconds ignoring 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 DiffInDays and DiffInWeeks computing incorrect results across DST transitions: dividing elapsed seconds gave wrong results when crossing a DST change; now counts calendar days the way DiffInMonths counts months (AddDate plus an adjustment), and DiffInWeeks uses it; only intervals that cross a DST transition change (by @youdie006 in #376)
Fix DiffInYears and DiffInMonths producing incorrect estimates when comparing dates across different time zones: the first estimate from each date's own Year() / 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 frame DiffInDays uses (by @ybai08 in #384)
Fix IsSameDecade not comparing the century: Decade() is the decade within the century, so Parse("1995-08-05").IsSameDecade(Parse("2095-08-05")) returned true; now also compares Century(), matching the buckets StartOfDecade uses (by @youdie006 in #375)
Fix FromStdTime returning 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, matching persian.FromStdTime and hebrew.FromStdTime (by @youdie006 in #380)
Fix race condition in frozen-clock mode where concurrent Sleep calls lost clock advances: concurrent Sleep calls on a frozen clock raced with each other and with Now, losing clock advances; now uses the existing frozen-clock mutex around the check and update (by @yuefdev in #383)