Skip to content

Add support for non-gregorian calendars #20

@javier-godoy

Description

@javier-godoy

In a thread in Vaadin Directory, Hussam Almulhim wrote:

Can I render the Cells, assuming I want to display a different calendar and do the conversion and show the info instead of the Gregorian calendar?

  • The implementation of this addon is based on Vaadin DatePicker, which unfortunately only supports the Gregorian calendar.

  • I did some attempts for implementing Hijrah (Umm Al-Qura) by using months with the "same shape" (for instance, use February 2000 as the basis for Rabi Ul Awal 1444, since both are 29-day months starting on Tuesday). It kinda works, but the API is a mess. Another approach would have been overwriting _getDays in vaadin-month-calendar in order to allow arbitrary months.
    image

  • Despite of that, there are everal calculations in fc-year-calendar that would also need refactoring. For instance, when navigating using the keyboard, we do an arithmetic operation on the Gregorian date in order to get the next week, next day in week, etc.

    //select the first day in month with the same date of week
    d = new Date(d.getFullYear(), month, 1);
    while (d.getDay()!=dayOfWeek) d = adjustDate(d, +1);
    } else {
    //select the last day in month with the same date of week
    d = new Date(d.getFullYear(), month+1, 0);
    while (d.getDay()!=dayOfWeek) d = adjustDate(d, -1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    Under consideration

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions