-
-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ethiopic calendar #2658
base: main
Are you sure you want to change the base?
feat: ethiopic calendar #2658
Conversation
|
That's wonderful, thanks! Based on your work there, would it be possible to code pure functions that we can unit test, a-la
From the "List of DateLib functions," which ones do you know for sure we have to add, and which ones can we just ignore? |
Interesting. Which numerals should we support? In my implementation, I could rely on Intl native object to switch to other numerals: react-day-picker/src/classes/DateLib.ts Lines 129 to 144 in 1f070c3
Are all the numerals used in the Ethiopic calendar included in the |
From my experience, I’ve identified these as essential practices, and I’ve already implemented them. I will convert them into pure functions and incorporate unit tests for the functions.
|
The only numeral we should consider is Geez. The numerals look like '፩', '፪', '፫', '፬'. But I don't think we have support for it on Intl. But the numerals shouldn't be the primary focus. Since most of us use Western Arabic numerals. |
I made some progress without knowing much about the Ethiopic calendar. I scaffolded utilities and functions with the help of Copilot, so they are not guaranteed to work. The next step is to write tests for each of them and then fix the functions to pass the tests.
I wonder work @temesgen-mulugeta's work on MUI (or even the ethiopian date package could be useful here. Still missing the formatting function. I wonder if we could use the |
I’ve been quite busy over the past week. I didn’t want to open a PR with an incomplete task, but I’ve now created one to assist you. |
As far as I know Intl doesn't provide date formatting for Ethiopian dates. So what I did was create a date formatting function for the formattings you use on the package. |
This PR introduces support for the Ethiopic calendar in the DayPicker.
The PR is still a work in progress. Switch to this branch to start applying changes to the source.
How It Works
The Ethiopic calendar is rendered by importing it from
react-day-picker/ethiopic
, similar to how we handle the Persian calendar.Understand the correct name, Ethiopian or Ethiopic?"Ethiopic" is correct.Ethiopic Module
Render DayPicker using the Ethiopic calendar, overriding some props. Complete tests.
Date manipulation and formatting functions compatible with DayPicker's DateLib. Complete tests and fix functions.
Convert dates from/to Gregorian. Complete tests and fix functions.
List of lib functions
addDays
addMonths
addWeeks
addYears
differenceInCalendarDays
differenceInCalendarMonths
eachMonthOfInterval
endOfBroadcastWeek
endOfISOWeek
endOfMonth
endOfWeek
endOfYear
format
formatNumber
getISOWeek
getMonth
getWeek
getYear
isAfter
isBefore
isSameDay
isSameMonth
isSameYear
max
min
newDate
setMonth
setYear
startOfBroadcastWeek
startOfDay
startOfISOWeek
startOfMonth
startOfWeek
startOfYear
today
Example Component and Docs
examples/Ethiopic.tsx
: the example components.examples/Ethiopic.test.tsx
: test file for the new Ethiopic calendar example.website/docs/docs/localization.mdx
: add Ethiopic Calendar paragraph.website/components/playground
: add Ethiopic Calendar option.Numeral System and Locale
src/types/props.ts
,src/types/shared.ts
: include the Ethiopic numeral system.DateLib
to work with the new numeral system (e.g.,getDigitMap
).Ethiopic DateLib
Having the Ethiopic date library compatible with the DateLib overrides protocol is the most challenging part of this project. The DateLib is initialized here with the Ethiopic overrides and should work out-of-the-box once we provide the correct functions.
In the absence of a package like
date-fns-ethiopic
, we can initially include the Ethiopic DateLib override functions in the DayPicker package. Note that not all functions may require an Ethiopic version.Configuration and Build
package.json
: includes the Ethiopic calendar module.ethiopic.js
: added module export for the Ethiopic calendar.