angular-hijri-gregorian-date-time-picker 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # Angular Hijri Gregorian Calendar(Datepicker)
2
+
3
+ [![Build](https://img.shields.io/badge/build-passing-green.svg)](https://www.npmjs.com/package/angular-hijri-gregorian-date-time-picker)
4
+ [![Dependencies](https://img.shields.io/badge/dependencies-uptodate-green.svg)](https://www.npmjs.com/package/angular-hijri-gregorian-date-time-picker)
5
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](https://www.npmjs.com/package/angular-hijri-gregorian-date-time-picker)
6
+
7
+ - Most accurate Hijri, Gregorian calendar(date-picker) on NPM with 100% accuracy percentage.
8
+ - Robust and tested code angular hijri/gregorian calendar/date-picker component for Angular 10 - 16, 18+ projects.
9
+ - Ionic 3 - 4, 5, 6 + is supported, can be used in iOS and Android.
10
+ - `Zero` dependents package.
11
+ - 10 different `themes` and `layouts` already built in, you can also customize your own as well.
12
+
13
+ ## Dependents
14
+
15
+ Angular hijri gregorian with `Zero` dependents that supports conversion between Gregorian and Hijri calendars.
16
+
17
+ <br />
18
+
19
+ ## Preview
20
+
21
+ <p>
22
+ <img src="https://github.com/hanygamal72/angular-hijri-gregorian-date-time-picker/blob/master/src/assets/imgs/themes_en.gif" width="40%"/>
23
+ <img src="https://github.com/hanygamal72/angular-hijri-gregorian-date-time-picker/blob/master/src/assets/imgs/themes_ar.gif" width="40%"/>
24
+ </p>
25
+
26
+ ## Background
27
+
28
+ The Umm Al-Qura calendar is the lunar Hijri calendar officially adopted by Saudi Arabia for administrative purposes. It was originated from Umm Al-Qura newspaper, the official newspaper of government of Saudi Arabia. The newspaper is published weekly and its first issue was on Friday, 15 Jumada al-Ula 1343 AH (12 December 1924 CE). However, the calendar has been printed and distributed separately by the Saudi government since 1346 AH (1927 CE).
29
+
30
+ The calendar is widely used in Saudi Arabia, especially by the public sector. Official documents, political letters, health care records, and education certificates, are just examples of many other documents that are dated by the Hijri calendar.
31
+
32
+ However, the Gregorian calendar is the calendar used in most of the world, and it has been implemented as the default calendar in nearly every computer and database.
33
+
34
+ <b> Star it to inspire us to build the best component! </b>
35
+
36
+ <br />
37
+
38
+ ## Features
39
+
40
+ - Can be used as a calendar or a datepicker.
41
+ - **RTL** and **LTR** support
42
+ - Easy to switch between **Gregorian** and **Hijri** calendars.
43
+ - Ability to specify the default calendar type either **Gregorian** or **Hijri**.
44
+ - Converting dates when changing type of calendar.
45
+ - Ability to specify min and max value for **Gregorian** and **Hijri**.
46
+ - Ability to make it required or readonly.
47
+ - Very easy to customize.
48
+ - Can select **Multiple** dates.
49
+ - **Event listeners** for all datepicker events.
50
+ - Can customize future and past years number.
51
+ - **Responsive** desing for web and mobile.
52
+
53
+ <br />
54
+
55
+ ## Supported platforms
56
+
57
+ <b>Angular</b> 10 - 16, 18 +<br />
58
+ <b>Ionic</b> 3 - 4, 5, 6 +<br />
59
+ Mobile browsers and WebViews on: <b>Android</b> and <b>iOS</b><br />
60
+ Desktop browsers: <b>Chrome, Firefox, Safari, Edge v.79 +</b><br />
61
+ Other browsers: <b>Edge v.41 - 44</b> (without code hidden feature)
62
+
63
+ <br />
64
+
65
+ ## Installation
66
+
67
+ $ npm install angular-hijri-gregorian-date-time-picker
68
+
69
+ <br />
70
+
71
+ ## Usage
72
+
73
+ Import `HijriGregorianDatepickerModule` in your app module or page module:
74
+
75
+ ```ts
76
+ import { HijriGregorianDatepickerModule } from 'angular-hijri-gregorian-date-time-picker';
77
+
78
+ @NgModule({
79
+ imports: [
80
+ // ...
81
+ HijriGregorianDatepickerModule
82
+ ]
83
+ })
84
+ ```
85
+
86
+ ```html
87
+ <hijri-gregorian-datepicker
88
+ [canChangeMode]="true"
89
+ [todaysDateSection]="true"
90
+ [futureValidation]="true"
91
+ [disableYearPicker]="false"
92
+ [disableMonthPicker]="false"
93
+ [disableDayPicker]="false"
94
+ [multiple]="true"
95
+ [isRequired]="false"
96
+ [showConfirmButton]="true"
97
+ [markToday]="true"
98
+ [mode]="'greg'"
99
+ [dir]="'ltr'"
100
+ [locale]="'en'"
101
+ [submitTextButton]="'Confirm'"
102
+ [todaysDateText]="'Today\'s Date'"
103
+ [ummAlQuraDateText]="'التاريخ الهجرى'"
104
+ [yearSelectLabel]="'Year'"
105
+ [monthSelectLabel]="'Month'"
106
+ [futureValidationMessageEn]="'Selected date cannot be in the future!'"
107
+ [futureValidationMessageAr]="
108
+ 'التاريخ المحدد لا يمكن ان يكون في المستقبل!'
109
+ "
110
+ [pastYearsLimit]="90"
111
+ [futureYearsLimit]="0"
112
+ [theme]="'Midnight Blue'"
113
+ [styles]="stylesConfig"
114
+ (onSubmit)="onSubmit($event)"
115
+ (onDaySelect)="onChange($event)"
116
+ (onMonthChange)="onMonthChangeTest($event)"
117
+ (onYearChange)="onYearChangeTest($event)"
118
+ ></hijri-gregorian-datepicker>
119
+ ```
120
+
121
+ Inside your component.ts:
122
+
123
+ ```ts
124
+ // this called every time when user confirms a selected date
125
+ onSubmitEvent(code: string) {
126
+ }
127
+
128
+ // this called only every time the use selects a date
129
+ onChangeEvent(code: string) {
130
+ }
131
+
132
+ // this called every time the month value channges
133
+ onMonthChangeEvent(code: string) {
134
+ }
135
+
136
+ // this called every time the year value channges
137
+ onYearChangeEvent(code: string) {
138
+ }
139
+ ```
140
+
141
+ <br />
142
+
143
+ ## @Inputs()
144
+
145
+ | Property | Type | Default | Description |
146
+ | ---------------------------------- | :-----: | :-------------------------------------------: | ---------------------------------------------------------------------------------------------------------------- |
147
+ | <b>`canChangeMode`</b> | boolean | `true` | When `true` the user can toggle calendar modes, if `false` the user has only one calendar mode |
148
+ | <b>`todaysDateSection`</b> | boolean | `true` | When `true` the section with current today date will be shown, if `false` it will be hidden |
149
+ | <b>`futureValidation`</b> | boolean | `true` | When `true` the user cannot choose any future dates, if `false` user can select future dates |
150
+ | <b>`disableYearPicker`</b> | boolean | `false` | When `true` the user cannot select different years, if `false` year select will be enabled |
151
+ | <b>`disableMonthPicker`</b> | boolean | `false` | When `true` the user cannot select different months, if `false` month select will be enabled |
152
+ | <b>`disableDayPicker`</b> | boolean | `false` | When `true` the user cannot select days, if `false` days select will be enabled |
153
+ | <b>`multiple`</b> | boolean | `false` | When `true` the user can select multiple days, if `false` only one date can be selected |
154
+ | <b>`isRequired`</b> | boolean | `true` | When `true` the confirm button will be disabled until user selects a date, if `false` the button will be enabled |
155
+ | <b>`showConfirmButton`</b> | boolean | `true` | When `true` the confirm button will be displayed, if `false` it will be hidden |
156
+ | <b>`markToday`</b> | boolean | `true` | When `true` today date will be marked(bordered), if `false` it will not be marked |
157
+ | <b>`mode`</b> | string | `greg` | Calendar mode, either `ummAlQura` or `greg` |
158
+ | <b>`dir`</b> | string | `ltr` | Layout direction, either `ltr` or `rtl` |
159
+ | <b>`locale`</b> | string | `en` | The language of the calendar layout, either `ar` or `en` |
160
+ | <b>`submitTextButton`</b> | string | `Confirm` | Confirm button text value |
161
+ | <b>`todaysDateText`</b> | string | `Todays\'s Date` | Today's date text in `todaysDateSection` |
162
+ | <b>`ummAlQuraDateText`</b> | string | `التاريخ الهجرى` | Text next to checkbox to toggle date `todaysDateSection` |
163
+ | <b>`yearSelectLabel`</b> | string | `Year` | Label of the year select option |
164
+ | <b>`monthSelectLabel`</b> | string | `Month` | Label of the month select option |
165
+ | <b>`futureValidationMessageEn`</b> | string | `Selected date cannot be in the future!` | English future validation message if `futureValidation` is set to `true` |
166
+ | <b>`futureValidationMessageAr`</b> | string | `التاريخ المحدد لا يمكن ان يكون في المستقبل!` | Arabic future validation message if `futureValidation` is set to `true` |
167
+ | <b>`pastYearsLimit`</b> | number | `90` | indicates for the past years number you want to allow user to select from |
168
+ | <b>`futureYearsLimit`</b> | number | `0` | indicates for the future years number you want to allow user to select from |
169
+ | <b>`styles`</b> | object | `{}` | Styles for the calendar look and feel |
170
+ | <b>`theme`</b> | string | `Midnight Blue` | Different skins and themes for the calendar('Ocean Breeze', 'Lavender Dreams', 'Sunset Glow', 'Midnight Blue', 'Forest Canopy', 'Rosewood Elegance', 'Icy Mint', 'Golden Sand', 'Steel Grey', 'Coral Reef'), and it has priority over styles
171
+
172
+ <br />
173
+
174
+ ## Styles
175
+
176
+ | Property | Type | Default | Description |
177
+ | ---------------------------- | :----: | :---------------: | -------------------------------------------------------------------- |
178
+ | <b>`backgroundColor`</b> | string | `#E3F6F5` | Background of the calendar |
179
+ | <b>`primaryColor`</b> | string | `#272343` | Color of the today's date, year and month texts |
180
+ | <b>`secondaryColor`</b> | string | `#272343` | Background of submit button and selected days in calendar |
181
+ | <b>`todaysDateBgColor`</b> | string | `#272343` | Background of "today's date" date section |
182
+ | <b>`todaysDateTextColor`</b> | string | `#fff` | Color of "today's date" date section text |
183
+ | <b>`confirmBtnTextColor`</b> | string | `#fff` | Color of "Confirm" button text |
184
+ | <b>`disabledDayColor`</b> | string | `#C0C0C0` | Disabled days text color |
185
+ | <b>`dayNameColor`</b> | string | `#0d7f91` | Day names text color |
186
+ | <b>`dayColor`</b> | string | `#000` | Enabled days text color |
187
+ | <b>`fontFamily`</b> | string | `Default-Regular` | Font family of the font used globally and pre defined within project |
188
+ | <b>`borderRadius`</b> | string | `8px` | Border radius of the each div and button in the calendar layout |
189
+
190
+
191
+ <br />
192
+
193
+ ## @Outputs()
194
+
195
+ | Output | Description |
196
+ | --------------- | ------------------------------------------------------------- |
197
+ | `onSubmit` | Will be called every time when a user submits a selected date |
198
+ | `onDaySelect` | Will be called every time when a user selects new date |
199
+ | `onMonthChange` | Will be called every time the month value changes |
200
+ | `onYearChange` | Will be called every time the year value changes |
201
+
202
+ <br />
203
+
204
+ ## Helper Functions
205
+
206
+ import { DateUtilitiesService } from '../_services/date-utilities.service';
207
+
208
+ ```ts
209
+ constructor(private _dateUtils: DateUtilitiesService) {
210
+
211
+ }
212
+
213
+ ```
214
+
215
+ | Output | Description |
216
+ | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
217
+ | <b>`convertDate`</b> | Converts dates from Gregorian to Umm Al Qura and vice versa |
218
+ | <b>`checkPastOrFuture`</b> | Checks date whether it's future or past date('Future', 'Past', 'Today') |
219
+ | <b>`formatDate`</b> | Converts date from human-readable string representation(ex. Mon Sep 05 2023 15:30:45 GMT+0200) to separated "/" string(ex. 05/09/2023) |
220
+ | <b>`parseDate`</b> | The opposite of `formateDate` function |
221
+ | <b>`getGregorianMonthData`</b> | Generates an array of objects of Gregorian month passed to it |
222
+ | <b>`getUmAlQurraMonthData`</b> | Generates an array of objects of Umm Al Qura month passed to it |
223
+
224
+ <br />
225
+
226
+ ## Contributing
227
+
228
+ Contributions are more than welcome!
229
+
230
+ <br />
231
+
232
+ ## License
233
+
234
+ MIT License
235
+
236
+ Copyright (c) 2022 Muhammad Hanafi, Imad Khan
@@ -0,0 +1,28 @@
1
+ export interface MonthInfo {
2
+ fD: DayInfo;
3
+ lD: DayInfo;
4
+ }
5
+ export interface YearData {
6
+ [month: string]: MonthInfo;
7
+ }
8
+ export interface Data {
9
+ [year: string]: YearData;
10
+ }
11
+ export interface TimeValue {
12
+ hour: number;
13
+ minute: number;
14
+ }
15
+ export interface DayInfo {
16
+ gD: string;
17
+ uD: string;
18
+ dN: string;
19
+ uC: number;
20
+ selected?: boolean;
21
+ disabled?: boolean;
22
+ time?: TimeValue;
23
+ }
24
+ export interface TodayDate {
25
+ gregorian?: string;
26
+ ummAlQura?: string;
27
+ }
28
+ export type MonthDays = DayInfo[];
@@ -0,0 +1,13 @@
1
+ export interface stylesConfig {
2
+ backgroundColor?: string;
3
+ primaryColor?: string;
4
+ secondaryColor?: string;
5
+ todaysDateBgColor?: string;
6
+ todaysDateTextColor?: string;
7
+ confirmBtnTextColor?: string;
8
+ disabledDayColor?: string;
9
+ dayNameColor?: string;
10
+ dayColor?: string;
11
+ fontFamily?: string;
12
+ borderRadius?: string;
13
+ }
@@ -0,0 +1,49 @@
1
+ import { Data, DayInfo, MonthDays } from '../_interfaces/calendar-model';
2
+ import * as i0 from "@angular/core";
3
+ export declare class DateUtilitiesService {
4
+ calendarData: Data;
5
+ constructor();
6
+ parseDate(dateStr: string): Date | null;
7
+ formatDate(date: Date): string;
8
+ getDayShortHand(date: Date): string;
9
+ generateDates(fD: DayInfo, lD: DayInfo, uC: number): MonthDays;
10
+ convertDate(dateStr: string, isGregorian: boolean): DayInfo | null;
11
+ private isDateInMonthRange;
12
+ getMonthData(inputDate: string, type: string): DayInfo[] | null;
13
+ getGregorianMonthData(day: number, month: number, year: number): DayInfo[] | null;
14
+ getUmAlQurraMonthData(day: number, month: number, year: number): DayInfo[] | null;
15
+ calculateGregorianDate(startGDate: string, offset: number): string;
16
+ calculateUmAlQurraDate(startUDate: string, offset: number, uC: number): string;
17
+ getDayName(dayIndex: number): string;
18
+ checkPastOrFuture(inputDate: any, targetDate: any): "Future" | "Past" | "Today";
19
+ parseEnglish(englishNum: any): any;
20
+ parseArabic(arabicNum: any): any;
21
+ convertDateNumerals(date: string, targetLang: 'en' | 'ar'): string;
22
+ /**
23
+ * Normalize input date to DD/MM/YYYY string format (Gregorian)
24
+ * Accepts Date object or DD/MM/YYYY string
25
+ */
26
+ normalizeDateToString(date: Date | string | undefined): string | null;
27
+ /**
28
+ * Compare two dates (Gregorian format DD/MM/YYYY)
29
+ * Returns: -1 if date1 < date2, 0 if equal, 1 if date1 > date2
30
+ */
31
+ compareDates(date1Str: string, date2Str: string): number;
32
+ /**
33
+ * Compare two Hijri dates (UM format DD/MM/YYYY)
34
+ * Converts to Gregorian for comparison
35
+ */
36
+ compareHijriDates(hijri1: string, hijri2: string): number;
37
+ /**
38
+ * Check if a date is within the specified range (inclusive)
39
+ * All dates in Gregorian DD/MM/YYYY format
40
+ */
41
+ isDateInRange(dateStr: string, minDateStr: string | null, maxDateStr: string | null): boolean;
42
+ /**
43
+ * Check if a Hijri date is within the specified range
44
+ * Converts to Gregorian for comparison
45
+ */
46
+ isHijriDateInRange(hijriDateStr: string, minDateStr: string | null, maxDateStr: string | null): boolean;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<DateUtilitiesService, never>;
48
+ static ɵprov: i0.ɵɵInjectableDeclaration<DateUtilitiesService>;
49
+ }