-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from 5 commits
4fd3531
c32482f
84e3f77
19ca522
a694c6a
1054689
ca58456
200f650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ sudo: required | |
language: node_js | ||
|
||
node_js: | ||
- "8" | ||
- "10.9.0" | ||
|
||
cache: | ||
directories: | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -25,10 +25,10 @@ import { | |||||||||||||||||
CalendarPeriod, | ||||||||||||||||||
GregorianCalendarDate, | ||||||||||||||||||
JDNConvertibleCalendar, | ||||||||||||||||||
JDNConvertibleConversionModule, | ||||||||||||||||||
JDNPeriod, | ||||||||||||||||||
JulianCalendarDate | ||||||||||||||||||
} from 'jdnconvertiblecalendar'; | ||||||||||||||||||
import {JDNConvertibleCalendarModule} from "jdnconvertiblecalendar/dist/src/JDNConvertibleCalendar"; | ||||||||||||||||||
import IslamicCalendarDate = JDNConvertibleCalendarModule.IslamicCalendarDate; | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
@Injectable() | ||||||||||||||||||
|
@@ -105,6 +105,10 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
this._activeCalendarFormat = 'Julian'; | ||||||||||||||||||
return dateMod.convertCalendar('Julian'); | ||||||||||||||||||
|
||||||||||||||||||
case 'Islamic': | ||||||||||||||||||
this._activeCalendarFormat = 'Islamic'; | ||||||||||||||||||
return dateMod.convertCalendar('Islamic'); | ||||||||||||||||||
|
||||||||||||||||||
default: | ||||||||||||||||||
// invalid format | ||||||||||||||||||
return dateMod; | ||||||||||||||||||
|
@@ -138,8 +142,11 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
getMonthNames(style: 'long' | 'short' | 'narrow'): string[] { | ||||||||||||||||||
// TODO: implement this properly, taking calendar format and locale into account | ||||||||||||||||||
return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']; | ||||||||||||||||||
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']; | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
getDateNames(): string[] { | ||||||||||||||||||
|
@@ -153,8 +160,11 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
getDayOfWeekNames(style: 'long' | 'short' | 'narrow') { | ||||||||||||||||||
// TODO: implement this properly, taking calendar format and locale into account | ||||||||||||||||||
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat']; | ||||||||||||||||||
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']; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlQuraian @benjamingeer Could you have a look at the weekdays? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
getYearName(date: JDNConvertibleCalendar): string { | ||||||||||||||||||
|
@@ -182,6 +192,9 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
|
||||||||||||||||||
case 'Julian': | ||||||||||||||||||
return new JulianCalendarDate(jdnPeriod); | ||||||||||||||||||
|
||||||||||||||||||
case 'Islamic': | ||||||||||||||||||
return new IslamicCalendarDate(jdnPeriod); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
} | ||||||||||||||||||
|
@@ -205,6 +218,9 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
|
||||||||||||||||||
case 'Julian': | ||||||||||||||||||
return new JulianCalendarDate(new CalendarPeriod(calDate, calDate)); | ||||||||||||||||||
|
||||||||||||||||||
case 'Islamic': | ||||||||||||||||||
return new IslamicCalendarDate(new CalendarPeriod(calDate, calDate)); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -356,8 +372,6 @@ export class JDNConvertibleCalendarDateAdapter extends DateAdapter<JDNConvertibl | |||||||||||||||||
|
||||||||||||||||||
const gregorianCalPeriod = gregorianCal.toCalendarPeriod(); | ||||||||||||||||||
|
||||||||||||||||||
console.log('to iso'); | ||||||||||||||||||
|
||||||||||||||||||
return `${JDNConvertibleCalendarDateAdapter.addLeadingZeroToNumber(gregorianCalPeriod.periodStart.year, 4)}-${JDNConvertibleCalendarDateAdapter.addLeadingZeroToNumber(gregorianCalPeriod.periodStart.month, 2)}-${JDNConvertibleCalendarDateAdapter.addLeadingZeroToNumber(gregorianCalPeriod.periodStart.day, 2)}`; | ||||||||||||||||||
|
||||||||||||||||||
} | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mmalerba After conversion to the Islamic calendar, the weekdays are not updated: 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 |
||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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:
We can look at this next week.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend reading this: https://www.w3.org/International/articles/inline-bidi-markup/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM