Support for custom calendar with @internationalized/dates #3665
Replies: 2 comments 6 replies
-
I thought this issue provided a workaround for something similar. |
Beta Was this translation helpful? Give feedback.
-
You have the right idea with extending the function createCalendar(identifier) {
if (identifier === 'gregory') {
return new BroadcastCalendar();
}
// throw?
} You can also force the Gregorian calendar to always be used regardless of the user's locale setting by overriding it (e.g. One part that isn't quite possible yet is forcing the week start to be Monday regardless of locale. The startOfWeek function accepts a locale argument, and uses that to determine the first day of the week. We could potentially add an optional Let us know how it goes and if you run into other issues. Kyle linked to #3270 which is a related issue for other custom calendars, so any work done here should also benefit others. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to create a custom calendar? I'm trying to create a Broadcast calendar.
I tried duplicating the Gregorian calendar with different calculations and a new identifier of "broadcast" but I can't use it with useCalendarState, because it restricts you to the built-in calendars via createCalendar (even when overriding the createCalendar function).
Background on the Broadcast Calendar - Wikipedia
The broadcast calendar is a standardized calendar used primarily for the planning and purchasing of radio and television programs and advertising. Every week in the broadcast calendar starts on a Monday and ends on a Sunday, and every month has either four or five such weeks. Broadcast calendar months thus have either 28 or 35 days.
The first week of every broadcast month always contains the Gregorian calendar first of the month. For example, if January 1 falls on a Saturday, then the broadcast calendar year would begin on the preceding Monday, December 27. Broadcast January would then have five weeks, ending on January 30, and the four weeks of broadcast February would begin on January 31. The number of weeks in a broadcast month is based on the number of Sundays that fall in that month with the period ending on the last Sunday of the month.
Thanks for your time.
Beta Was this translation helpful? Give feedback.
All reactions