Skip to content
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

Add support for the Islamic calendar #15

Merged
merged 8 commits into from
Aug 19, 2019
Merged

Conversation

tobiasschweizer
Copy link
Contributor

@tobiasschweizer tobiasschweizer commented Jun 17, 2019

This PR adds support for conversion from and to Islamic calendar dates.

see angular/components#2519

@tobiasschweizer tobiasschweizer self-assigned this Jun 17, 2019
if (this._activeCalendarFormat === 'Julian' || this._activeCalendarFormat === 'Gregorian') {
return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
} else if (this._activeCalendarFormat === 'Islamic') {
return ['Muharram', 'Safar', 'Rabīʿ al Awwal','Rabīʿ al Ththānī', 'Jumādá al Ūlá', 'Jumādá al Ākhirah', 'Rajab','Sha‘bān', 'Ramadān','Shawwāl','Dhū al Qa‘dah', 'Dhū al Hijjah'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlQuraian @benjamingeer Could you have a look at the month names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamingeer Could we have look at this next week? We can also try without transliteration, but perhaps there will be RTL issue (CSS).

Copy link

@benjamingeer benjamingeer Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally both Arabic script and transliteration would be supported. I would transliterate them like this:

Transliteration Arabic
Muḥarram محرم
Ṣafar صفر
Rabīʿ al-Awwal ربيع الأول
Rabīʿ al-Thānī ربيع الثاني
Jumādā al-Ūlā جمادى الأولى
Jumādā al-Ākhirah جمادى الآخرة
Rajab رجب
Shaʿbān شعبان
Ramaḍān رمضان
Shawwāl شوال
Dhū al-Qaʿdah ذو القعدة
Dhū al-Ḥijjah ذو الججة

We can look at this next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you very much!

I have to see how the UI behaves with Arabic script.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (this._activeCalendarFormat === 'Julian' || this._activeCalendarFormat === 'Gregorian') {
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'];
} else if (this._activeCalendarFormat === 'Islamic') {
return ['al-Aḥad', 'al-Ithnayn', 'ath-Thulāthā’', ' al-Arba‘ā’', 'al-Khamīs', 'al-Jumu\'ah', 'as-Sabt'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlQuraian @benjamingeer Could you have a look at the weekdays?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transliteration Arabic
al-Aḥad الأحد
al-Ithnayn الإثنين
al-Thulāthāʾ الثلاثاء
al-Arbiʿāʾ الأربعاء
al-Khamīs الخميس
al-Jumʿah الجمعة‎
al-Sabt السبت

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlQuraian Thanks! Once this PR is merged, I will come up with a stackblitz example to try it out.

@@ -76,7 +76,7 @@ export class HeaderComponent<D> implements OnInit {
*
* @param {"Gregorian" | "Julian"} calendar the target calendar format.
*/
convertCalendar(calendar: 'Gregorian' | 'Julian') {
convertCalendar(calendar: 'Gregorian' | 'Julian' | 'Islamic') {

if (this._dateAdapter instanceof JDNConvertibleCalendarDateAdapter) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmalerba After conversion to the Islamic calendar, the weekdays are not updated:

conversion

However, when I close and reopen the datepicker widget, the names are updated correctly.

Do I have to call an additional method after each conversion (similar to updateTodaysDate)?

@@ -87,6 +88,9 @@ export class HeaderComponent<D> implements OnInit {
this._datepickerContent.datepicker.select(convertedDate);

this._calendar.updateTodaysDate();

this._datepickerIntl.changes.next();
Copy link
Contributor Author

@tobiasschweizer tobiasschweizer Jul 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mmalerba This does not have the desired effect; the labels of the weekdays are not updated. Could you point out to me what needs to be changed in the parent that receives this event?

I guess this would need to happen in calendar.ts:

this._intlChanges = _intl.changes.subscribe(() => {
      _changeDetectorRef.markForCheck();
      this.stateChanges.next();
    });

https://github.com/angular/components/blob/2a04ccfd46c154cc5a23993cda8dff3474f2248c/src/material/datepicker/calendar.ts#L304-L308

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the issue is in month-view: https://github.com/angular/components/blob/master/src/material/datepicker/month-view.ts#L155

It needs to do something similar to what the calendar is doing there, to update this list of weekday names

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to do something similar to what the calendar is doing there, to update this list of weekday names

So it should subscribe to MatDatepickerIntl.changes too?

I wonder why the names of the months are updated.

Tobias Schweizer added 2 commits August 19, 2019 10:09
@tobiasschweizer tobiasschweizer merged commit 956cb3f into develop Aug 19, 2019
@tobiasschweizer tobiasschweizer deleted the wip/Islamic_calendar branch August 19, 2019 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants