@acorex/core 7.2.5 → 7.2.7

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.
@@ -143,10 +143,10 @@ export class AXPlatform {
143
143
  // init functions
144
144
  this._setFullHeightRatio();
145
145
  }
146
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXPlatform, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
147
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXPlatform, providedIn: 'root' }); }
146
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXPlatform, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
147
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXPlatform, providedIn: 'root' }); }
148
148
  }
149
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXPlatform, decorators: [{
149
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXPlatform, decorators: [{
150
150
  type: Injectable,
151
151
  args: [{
152
152
  providedIn: 'root',
@@ -2,11 +2,11 @@ import { NgModule } from '@angular/core';
2
2
  import { AXTranslatorPipe } from './translator.pipe';
3
3
  import * as i0 from "@angular/core";
4
4
  export class AXTranslationModule {
5
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXTranslationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
6
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXTranslationModule, declarations: [AXTranslatorPipe], exports: [AXTranslatorPipe] }); }
7
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXTranslationModule }); }
5
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXTranslationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
6
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: AXTranslationModule, declarations: [AXTranslatorPipe], exports: [AXTranslatorPipe] }); }
7
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXTranslationModule }); }
8
8
  }
9
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXTranslationModule, decorators: [{
9
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXTranslationModule, decorators: [{
10
10
  type: NgModule,
11
11
  args: [{
12
12
  imports: [],
@@ -5,10 +5,10 @@ export class AXTranslatorPipe {
5
5
  transform(value, arg1, arg2) {
6
6
  return AXTranslator.get(value, arg1, arg2);
7
7
  }
8
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
9
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXTranslatorPipe, name: "trans" }); }
8
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXTranslatorPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
9
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: AXTranslatorPipe, name: "trans" }); }
10
10
  }
11
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXTranslatorPipe, decorators: [{
11
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXTranslatorPipe, decorators: [{
12
12
  type: Pipe,
13
13
  args: [{ name: 'trans', pure: true }]
14
14
  }] });
@@ -26,10 +26,10 @@ class AXConfig {
26
26
  }
27
27
 
28
28
  class AXConfigService {
29
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
30
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXConfigService, providedIn: 'platform' }); }
29
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
30
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXConfigService, providedIn: 'platform' }); }
31
31
  }
32
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXConfigService, decorators: [{
32
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXConfigService, decorators: [{
33
33
  type: Injectable,
34
34
  args: [{ providedIn: 'platform' }]
35
35
  }] });
@@ -303,10 +303,10 @@ class AXDateTimePipe {
303
303
  return date.format(format);
304
304
  }
305
305
  }
306
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
307
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, name: "axDate" }); }
306
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
307
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimePipe, name: "axDate" }); }
308
308
  }
309
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, decorators: [{
309
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimePipe, decorators: [{
310
310
  type: Pipe,
311
311
  args: [{ name: 'axDate' }]
312
312
  }], ctorParameters: function () { return []; } });
@@ -505,6 +505,13 @@ class JalaliCalendar {
505
505
  this.monthShortNames = 'فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند'.split('_');
506
506
  this.dayNames = 'شنبه_یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه'.split('_');
507
507
  this.dayShortNames = 'ش_ی_د_س_چ_پ_ج'.split('_');
508
+ /*
509
+ Jalaali years starting the 33-year rule.
510
+ */
511
+ this.breaks = [
512
+ -61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192, 2262, 2324, 2394,
513
+ 2456, 3178,
514
+ ];
508
515
  }
509
516
  create(value) {
510
517
  const a = this.toGregorian(value.year, value.month, value.date);
@@ -514,10 +521,10 @@ class JalaliCalendar {
514
521
  return 'jalali';
515
522
  }
516
523
  dayOfMonth(date) {
517
- return this.toJalali(date).day;
524
+ return this.toJalaali(date).day;
518
525
  }
519
526
  dayOfYear(date) {
520
- const j = this.toJalali(date);
527
+ const j = this.toJalaali(date);
521
528
  return (j.month <= 6 ? (j.month - 1) * 31 : 6 * 31 + (j.month - 7) * 30) + j.day;
522
529
  }
523
530
  dayOfWeek(date) {
@@ -529,10 +536,10 @@ class JalaliCalendar {
529
536
  return Math.ceil(((date.getTime() - firstDay.date.getTime()) / 86400000 + firstDay.date.getDay() + 1) / 7);
530
537
  }
531
538
  year(date) {
532
- return this.toJalali(date).year;
539
+ return this.toJalaali(date).year;
533
540
  }
534
541
  monthOfYear(date) {
535
- return this.toJalali(date).month;
542
+ return this.toJalaali(date).month;
536
543
  }
537
544
  add(date, unit, amount) {
538
545
  let value = date.valueOf();
@@ -589,7 +596,7 @@ class JalaliCalendar {
589
596
  }
590
597
  set(date, unit, value) {
591
598
  const clone = new Date(date.valueOf());
592
- const jDate = this.toJalali(clone);
599
+ const jDate = this.toJalaali(clone);
593
600
  switch (unit) {
594
601
  case 'second':
595
602
  clone.setHours(clone.getHours(), clone.getMinutes(), value, clone.getMilliseconds());
@@ -673,20 +680,23 @@ class JalaliCalendar {
673
680
  case 'month': {
674
681
  const jy = this.year(date);
675
682
  const jm = this.monthOfYear(date);
676
- const jd = this.monthLength(jy, jm);
683
+ const jd = this.jalaaliMonthLength(jy, jm);
677
684
  const gDate = this.toGregorian(jy, jm, jd);
678
685
  return new AXDateTime(gDate, this.name()).endOf('day');
679
686
  }
680
687
  case 'year':
681
688
  let jy = this.year(date);
682
- const gDate = this.toGregorian(jy, 12, this.monthLength(jy, 12));
689
+ const gDate = this.toGregorian(jy, 12, this.jalaaliMonthLength(jy, 12));
683
690
  return new AXDateTime(gDate, this.name()).endOf('day');
684
691
  }
685
692
  }
686
- toJalali(date) {
687
- const gy = date.getFullYear();
688
- const gm = date.getMonth() + 1;
689
- const gd = date.getDate();
693
+ /*
694
+ Converts a Gregorian date to Jalaali.
695
+ */
696
+ toJalaali(date) {
697
+ let gd = date.getDate();
698
+ let gm = date.getMonth() + 1;
699
+ let gy = date.getFullYear();
690
700
  const r = this.d2j(this.g2d(gy, gm, gd));
691
701
  return {
692
702
  year: r.jy,
@@ -695,47 +705,75 @@ class JalaliCalendar {
695
705
  };
696
706
  }
697
707
  /*
698
- Converts a Jalaali date to Gregorian.
699
- */
708
+ Converts a Jalaali date to Gregorian.
709
+ */
700
710
  toGregorian(jy, jm, jd) {
701
711
  const g = this.d2g(this.j2d(jy, jm, jd));
702
712
  return new Date(g.gy, g.gm - 1, g.gd);
703
713
  }
704
714
  /*
705
- Checks whether a Jalaali date is valid or not.
706
- */
707
- isValid(jy, jm, jd) {
708
- return (jy >= -61 && jy <= 3177 && jm >= 1 && jm <= 12 && jd >= 1 && jd <= this.monthLength(jy, jm));
715
+ Checks whether a Jalaali date is valid or not.
716
+ */
717
+ isValidJalaaliDate(jy, jm, jd) {
718
+ return (jy >= -61 &&
719
+ jy <= 3177 &&
720
+ jm >= 1 &&
721
+ jm <= 12 &&
722
+ jd >= 1 &&
723
+ jd <= this.jalaaliMonthLength(jy, jm));
709
724
  }
710
725
  /*
711
- Is this a leap year or not?
712
- */
713
- isLeapYear(jy) {
714
- return this.jalCal(jy).leap === 0;
726
+ Is this a leap year or not?
727
+ */
728
+ isLeapJalaaliYear(jy) {
729
+ return this.jalCalLeap(jy) === 0;
715
730
  }
716
731
  /*
717
- Number of days in a given month in a Jalaali year.
718
- */
719
- monthLength(jy, jm) {
732
+ Number of days in a given month in a Jalaali year.
733
+ */
734
+ jalaaliMonthLength(jy, jm) {
720
735
  if (jm <= 6)
721
736
  return 31;
722
737
  if (jm <= 11)
723
738
  return 30;
724
- if (this.isLeapYear(jy))
739
+ if (this.isLeapJalaaliYear(jy))
725
740
  return 30;
726
741
  return 29;
727
742
  }
728
- jalCal(jy) {
729
- // Jalaali years starting the 33-year rule.
730
- let breaks = [
731
- -61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192, 2262, 2324,
732
- 2394, 2456, 3178,
733
- ], bl = breaks.length, gy = jy + 621, leapJ = -14, jp = breaks[0], jm, jump, leap, leapG, march, n, i;
734
- if (jy < jp || jy >= breaks[bl - 1])
743
+ /*
744
+ This determines if the Jalaali (Persian) year is
745
+ leap (366-day long) or is the common year (365 days)
746
+
747
+ @param jy Jalaali calendar year (-61 to 3177)
748
+ @returns number of years since the last leap year (0 to 4)
749
+ */
750
+ jalCalLeap(jy) {
751
+ let bl = this.breaks.length, jp = this.breaks[0], jm, jump, leap, n, i;
752
+ if (jy < jp || jy >= this.breaks[bl - 1])
753
+ throw new Error('Invalid Jalaali year ' + jy);
754
+ for (i = 1; i < bl; i += 1) {
755
+ jm = this.breaks[i];
756
+ jump = jm - jp;
757
+ if (jy < jm)
758
+ break;
759
+ jp = jm;
760
+ }
761
+ n = jy - jp;
762
+ if (jump - n < 6)
763
+ n = n - jump + this.div(jump + 4, 33) * 33;
764
+ leap = this.mod(this.mod(n + 1, 33) - 1, 4);
765
+ if (leap === -1) {
766
+ leap = 4;
767
+ }
768
+ return leap;
769
+ }
770
+ jalCal(jy, withoutLeap) {
771
+ let bl = this.breaks.length, gy = jy + 621, leapJ = -14, jp = this.breaks[0], jm, jump, leap, leapG, march, n, i;
772
+ if (jy < jp || jy >= this.breaks[bl - 1])
735
773
  throw new Error('Invalid Jalaali year ' + jy);
736
774
  // Find the limiting years for the Jalaali year jy.
737
775
  for (i = 1; i < bl; i += 1) {
738
- jm = breaks[i];
776
+ jm = this.breaks[i];
739
777
  jump = jm - jp;
740
778
  if (jy < jm)
741
779
  break;
@@ -752,6 +790,9 @@ class JalaliCalendar {
752
790
  leapG = this.div(gy, 4) - this.div((this.div(gy, 100) + 1) * 3, 4) - 150;
753
791
  // Determine the Gregorian date of Farvardin the 1st.
754
792
  march = 20 + leapJ - leapG;
793
+ // return with gy and march when we don't need leap
794
+ if (withoutLeap)
795
+ return { gy: gy, march: march };
755
796
  // Find how many years have passed since the last leap year.
756
797
  if (jump - n < 6)
757
798
  n = n - jump + this.div(jump + 4, 33) * 33;
@@ -765,28 +806,13 @@ class JalaliCalendar {
765
806
  march: march,
766
807
  };
767
808
  }
768
- /*
769
- Converts a date of the Jalaali calendar to the Julian Day number.
770
- @param jy Jalaali year (1 to 3100)
771
- @param jm Jalaali month (1 to 12)
772
- @param jd Jalaali day (1 to 29/31)
773
- @return Julian Day number
774
- */
775
809
  j2d(jy, jm, jd) {
776
- let r = this.jalCal(jy);
810
+ let r = this.jalCal(jy, true);
777
811
  return this.g2d(r.gy, 3, r.march) + (jm - 1) * 31 - this.div(jm, 7) * (jm - 7) + jd - 1;
778
812
  }
779
- /*
780
- Converts the Julian Day number to a date in the Jalaali calendar.
781
- @param jdn Julian Day number
782
- @return
783
- jy: Jalaali year (1 to 3100)
784
- jm: Jalaali month (1 to 12)
785
- jd: Jalaali day (1 to 29/31)
786
- */
787
813
  d2j(jdn) {
788
814
  let gy = this.d2g(jdn).gy, // Calculate Gregorian year (gy).
789
- jy = gy - 621, r = this.jalCal(jy), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
815
+ jy = gy - 621, r = this.jalCal(jy, false), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
790
816
  // Find number of days that passed since 1 Farvardin.
791
817
  k = jdn - jdn1f;
792
818
  if (k >= 0) {
@@ -842,14 +868,27 @@ class JalaliCalendar {
842
868
  gd: gd,
843
869
  };
844
870
  }
871
+ jalaaliWeek(jy, jm, jd) {
872
+ let dayOfWeek = this.jalaaliToDateObject(jy, jm, jd, 0, 0, 0, 0).getDay();
873
+ let startDayDifference = dayOfWeek == 6 ? 0 : -(dayOfWeek + 1);
874
+ let endDayDifference = 6 + startDayDifference;
875
+ return {
876
+ saturday: this.d2j(this.j2d(jy, jm, jd + startDayDifference)),
877
+ friday: this.d2j(this.j2d(jy, jm, jd + endDayDifference)),
878
+ };
879
+ }
880
+ jalaaliToDateObject(jy, jm, jd, h = 0, m = 0, s = 0, ms = 0) {
881
+ let gregorianCalenderDate = this.toGregorian(jy, jm, jd);
882
+ return new Date(gregorianCalenderDate.getFullYear(), gregorianCalenderDate.getMonth() - 1, gregorianCalenderDate.getDate(), h || 0, m || 0, s || 0, ms || 0);
883
+ }
845
884
  /*
846
- Utility helper functions.
847
- */
885
+ Utility helper functions.
886
+ */
848
887
  div(a, b) {
849
- return a / b;
888
+ return ~~(a / b);
850
889
  }
851
890
  mod(a, b) {
852
- return a - (a / b) * b;
891
+ return a - ~~(a / b) * b;
853
892
  }
854
893
  }
855
894
 
@@ -872,11 +911,11 @@ class AXDateTimeModule {
872
911
  }
873
912
  });
874
913
  }
875
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
876
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] }); }
877
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule }); }
914
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
915
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] }); }
916
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimeModule }); }
878
917
  }
879
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, decorators: [{
918
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.5", ngImport: i0, type: AXDateTimeModule, decorators: [{
880
919
  type: NgModule,
881
920
  args: [{
882
921
  imports: [],