Repository navigation
Conversation
Baseline for getNowInCalendarString, convertFromIso8601ToString and addDaysToDateString in gregory, ethiopian, ethiopic, nepali and islamic, taken before switching them to multi-calendar-dates' date helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to 10.19.3 3.2.0 adds the formatCalendarDate / addToCalendarDate helpers. @dhis2/ui 10.19.3 (@dhis2-ui/calendar) depends on ^3.1.0 instead of the exact 3.0.0, so the lockfile keeps a single 3.x copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rings - getNowInCalendarString formats with formatCalendarDate instead of its own stringifyDate. - convertFromIso8601ToString / convertToIso8601ToString format with formatCalendarDate. This fixes convertFromIso8601ToString for the `ethiopic` calendar id, which gave the Amete Alem year (7516) instead of the era year (2016) because it only read eraYear for `ethiopian`. - addDaysToDateString adds the days in the calendar with addToCalendarDate, instead of converting to ISO and back through JS Date. The time part is kept as it is. - padWithZeros and the ISO formatDate helper are removed; nothing else uses them. - Re-enable the ethiopian addDaysToDateString test, which passes. The ethiopic regression snapshots change because of the eraYear fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.2.1 corrects the Nepali calendar data (dhis2/multi-calendar-dates#108). The regression snapshots are unchanged: the only affected Nepali year they cover is 2086, and only on 1 January, whose Jan-1 column didn't change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Contributor
|
🚀 Deployed on https://pr-609--dhis2-data-entry.netlify.app |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Use multi-calendar-dates' date helpers for calendar date strings
Follow-up to #604.
@dhis2/multi-calendar-dates3.2.0 addsformatCalendarDateandaddToCalendarDate, so the app's own date-string formatting and day arithmetic insrc/shared/date/can go.Dependency changes
@dhis2/multi-calendar-dates^3.1.0 → ^3.2.1 (dependency and resolution).@dhis2/ui^10.19.2 → ^10.19.3 (dependency and resolution). In 10.19.3,@dhis2-ui/calendardepends on^3.1.0instead of the exact3.0.0, so the lockfile keeps a single multi-calendar-dates copy (3.2.1) without relying on the resolution to override an exact pin.Code changes (
src/shared/date/)getNowInCalendarString:stringifyDateis replaced byformatCalendarDate(now, { includeTime: long }). The output is unchanged.convertFromIso8601ToString: formats withformatCalendarDate, which reads the year aseraYear ?? year. Before, it readeraYearonly forcalendar === 'ethiopian', so theethiopicid gave the Amete Alem year (7516-10-08instead of2016-10-08).getNowInCalendarStringalready handled both ids, so the two functions disagreed forethiopic.convertToIso8601ToString: formats the ISO result withformatCalendarDateinstead of padding the fields by hand. The output is unchanged.addDaysToDateString: adds the days in the calendar withaddToCalendarDate(date, { days }, calendar), instead of converting to ISO, addingdays * 24hto a JSDate, and converting back. The time part, if any, is kept as it is. Its only caller is the expiry-days check inuse-check-lock-status.js(selectedPeriod.endDate + expiryDays + 1).padWithZerosand the ISOformatDatehelper (andDAY_MS), which nothing else used.addDaysToDateStringtest indate-utils.test.jswas skipped; it passes now (it already passed on master), so it's re-enabled.period-selector-bar-item.jsx, which readseraYear/yearitself, andDateText's display formatting (which slices the string and showsHH:MM) are left as they are.What users will notice
Nothing, on a DHIS2 server. The server reports the Ethiopian calendar as
ethiopian, which was already handled; theethiopicfix only matters if that id is passed in. ForaddDaysToDateString, results are the same for every calendar tested; the difference is that adding days no longer goes through local time, so a date with a time part can't shift by an hour across a DST change.Regression snapshot results
src/shared/date/date-utils.regression.test.jssnapshotsgetNowInCalendarString(with a mocked current time),convertFromIso8601ToString,convertToIso8601ToStringandaddDaysToDateStringfor gregory, ethiopian, ethiopic, nepali and islamic (plus iso8601 and gregorian forconvertFromIso8601ToString). The baseline was committed before the change, on the current code.convertFromIso8601ToString: now gives the era year, e.g.2024-06-15→2016-10-08instead of7516-10-08. This is the fix described above, and it matchesgetNowInCalendarStringand theethiopianoutput.addDaysToDateString: the old version converted to ISO (reading the year as the era year) and back withconvertFromIso8601ToString(writing the Amete Alem year), so the year changed on every call:2016-02-30 +5gave7516-03-05, and7516-02-30 +5gave13016-03-05. It now keeps the year the input was in:2016-03-05and7516-03-05.These snapshots were updated on purpose.
Verification
CI=true yarn test: 598 tests passed (34 skipped), 25 snapshots passed.yarn lint: ESLint, Stylelint and Prettier pass on the repo's files. Note thatyarn lintfails on a fresh clone untilsrc/localeshas been generated by a build; this is unrelated to this PR.🤖 Generated with Claude Code