ngx-mat-calendar
Version:
A datepicker with nepali and english calendar support
2,460 lines • 128 kB
JavaScript
import { Injectable, EventEmitter, Component, ViewEncapsulation, Self, Optional, ViewChild, Output, Input, NgModule } from '@angular/core';
import { FormControl, NgControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatMenuTrigger, MatMenuModule } from '@angular/material/menu';
import * as moment_ from 'moment';
import { Subject } from 'rxjs';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSliderModule } from '@angular/material/slider';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { TextMaskModule } from 'angular2-text-mask';
var DateFormat;
(function (DateFormat) {
DateFormat["ddMMyyyy"] = "ddMMyyyy";
DateFormat["MMddyyyy"] = "MMddyyyy";
DateFormat["yyyyMMdd"] = "yyyyMMdd";
DateFormat["yyyyddMM"] = "yyyyddMM";
})(DateFormat || (DateFormat = {}));
var DateType;
(function (DateType) {
DateType[DateType["AD"] = 1] = "AD";
DateType[DateType["BS"] = 2] = "BS";
})(DateType || (DateType = {}));
var Language;
(function (Language) {
Language[Language["English"] = 0] = "English";
Language[Language["Nepali"] = 1] = "Nepali";
})(Language || (Language = {}));
var CalendarViewType;
(function (CalendarViewType) {
CalendarViewType[CalendarViewType["Both"] = 1] = "Both";
CalendarViewType[CalendarViewType["Year"] = 2] = "Year";
CalendarViewType[CalendarViewType["Month"] = 3] = "Month";
})(CalendarViewType || (CalendarViewType = {}));
var EFrequencyIn;
(function (EFrequencyIn) {
EFrequencyIn[EFrequencyIn["InDays"] = 1] = "InDays";
EFrequencyIn[EFrequencyIn["InMonth"] = 2] = "InMonth";
EFrequencyIn[EFrequencyIn["InWeek"] = 3] = "InWeek";
})(EFrequencyIn || (EFrequencyIn = {}));
class Month {
}
class Day {
}
const NDateD = [
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1970 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 32, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1971 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 1972 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 1973 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1974 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1975 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 1976 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 1977 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1978 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1979 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 1980 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1981 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1982 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1983 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 1984 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1985 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1986 },
{ M1: 31, M2: 32, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1987 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 1988 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1989 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1990 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 1991 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 1992 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1993 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1994 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 1995 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 1996 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1997 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 1998 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 1999 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2000 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2001 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2002 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2003 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2004 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2005 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2006 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2007 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 29, M12: 31, NYear: 2008 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2009 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2010 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2011 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2012 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2013 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2014 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2015 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2016 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2017 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2018 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2019 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2020 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2021 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2022 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2023 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2024 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2025 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2026 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2027 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2028 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 32, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2029 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2030 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2031 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2032 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2033 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2034 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 29, M12: 31, NYear: 2035 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2036 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2037 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2038 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2039 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2040 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2041 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2042 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2043 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2044 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2045 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2046 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2047 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2048 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2049 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2050 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2051 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2052 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2053 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2054 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2055 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 32, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2056 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2057 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2058 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2059 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2060 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2061 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2062 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2063 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2064 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2065 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 29, M12: 31, NYear: 2066 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2067 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2068 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2069 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2070 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2071 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2072 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2073 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2074 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2075 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2076 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2077 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2078 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2079 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2080 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2081 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2082 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2083 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2084 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 30, M6: 31, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2085 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2086 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2087 },
{ M1: 30, M2: 31, M3: 32, M4: 32, M5: 30, M6: 31, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2088 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2089 },
{ M1: 30, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 30, M12: 30, NYear: 2090 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2091 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2092 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 29, M12: 31, NYear: 2093 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2094 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2095 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2096 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2097 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2098 },
{ M1: 31, M2: 31, M3: 32, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2099 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 31, NYear: 2100 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 31, M7: 29, M8: 30, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2101 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2102 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2103 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2104 },
{ M1: 31, M2: 31, M3: 31, M4: 32, M5: 31, M6: 32, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2105 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2106 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 29, M11: 30, M12: 30, NYear: 2107 },
{ M1: 31, M2: 32, M3: 31, M4: 32, M5: 31, M6: 30, M7: 30, M8: 30, M9: 29, M10: 30, M11: 29, M12: 31, NYear: 2108 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2109 },
{ M1: 31, M2: 31, M3: 32, M4: 31, M5: 31, M6: 31, M7: 30, M8: 29, M9: 30, M10: 29, M11: 30, M12: 30, NYear: 2110 },
{ M1: 30, M2: 31, M3: 30, M4: 32, M5: 30, M6: 30, M7: 32, M8: 30, M9: 30, M10: 30, M11: 30, M12: 30, NYear: 2111 }
];
// tslint:disable-next-line:max-line-length
const BSADCal = [{ NYear: 1970, StartDate: '1913-04-13T00:00:00', EndDate: '1914-04-12T00:00:00' },
{ NYear: 1971, StartDate: '1914-04-13T00:00:00', EndDate: '1915-04-12T00:00:00' },
{ NYear: 1972, StartDate: '1915-04-13T00:00:00', EndDate: '1916-04-11T00:00:00' },
{ NYear: 1973, StartDate: '1916-04-12T00:00:00', EndDate: '1917-04-11T00:00:00' },
{ NYear: 1974, StartDate: '1917-04-12T00:00:00', EndDate: '1918-04-11T00:00:00' },
{ NYear: 1975, StartDate: '1918-04-12T00:00:00', EndDate: '1919-04-11T00:00:00' },
{ NYear: 1976, StartDate: '1919-04-12T00:00:00', EndDate: '1920-04-11T00:00:00' },
{ NYear: 1977, StartDate: '1920-04-12T00:00:00', EndDate: '1921-04-11T00:00:00' },
{ NYear: 1978, StartDate: '1921-04-12T00:00:00', EndDate: '1922-04-11T00:00:00' },
{ NYear: 1979, StartDate: '1922-04-12T00:00:00', EndDate: '1923-04-11T00:00:00' },
{ NYear: 1980, StartDate: '1923-04-12T00:00:00', EndDate: '1924-04-11T00:00:00' },
{ NYear: 1981, StartDate: '1924-04-12T00:00:00', EndDate: '1925-04-11T00:00:00' },
{ NYear: 1982, StartDate: '1925-04-12T00:00:00', EndDate: '1926-04-11T00:00:00' },
{ NYear: 1983, StartDate: '1926-04-12T00:00:00', EndDate: '1927-04-11T00:00:00' },
{ NYear: 1984, StartDate: '1927-04-12T00:00:00', EndDate: '1928-04-11T00:00:00' },
{ NYear: 1985, StartDate: '1928-04-12T00:00:00', EndDate: '1929-04-11T00:00:00' },
{ NYear: 1986, StartDate: '1929-04-12T00:00:00', EndDate: '1930-04-11T00:00:00' },
{ NYear: 1987, StartDate: '1930-04-12T00:00:00', EndDate: '1931-04-12T00:00:00' },
{ NYear: 1988, StartDate: '1931-04-13T00:00:00', EndDate: '1932-04-12T00:00:00' },
{ NYear: 1989, StartDate: '1932-04-13T00:00:00', EndDate: '1933-04-12T00:00:00' },
{ NYear: 1990, StartDate: '1933-04-13T00:00:00', EndDate: '1934-04-12T00:00:00' },
{ NYear: 1991, StartDate: '1934-04-13T00:00:00', EndDate: '1935-04-12T00:00:00' },
{ NYear: 1992, StartDate: '1935-04-13T00:00:00', EndDate: '1936-04-12T00:00:00' },
{ NYear: 1993, StartDate: '1936-04-13T00:00:00', EndDate: '1937-04-12T00:00:00' },
{ NYear: 1994, StartDate: '1937-04-13T00:00:00', EndDate: '1938-04-12T00:00:00' },
{ NYear: 1995, StartDate: '1938-04-13T00:00:00', EndDate: '1939-04-12T00:00:00' },
{ NYear: 1996, StartDate: '1939-04-13T00:00:00', EndDate: '1940-04-12T00:00:00' },
{ NYear: 1997, StartDate: '1940-04-13T00:00:00', EndDate: '1941-04-12T00:00:00' },
{ NYear: 1998, StartDate: '1941-04-13T00:00:00', EndDate: '1942-04-12T00:00:00' },
{ NYear: 1999, StartDate: '1942-04-13T00:00:00', EndDate: '1943-04-13T00:00:00' },
{ NYear: 2000, StartDate: '1943-04-14T00:00:00', EndDate: '1944-04-12T00:00:00' },
{ NYear: 2001, StartDate: '1944-04-13T00:00:00', EndDate: '1945-04-12T00:00:00' },
{ NYear: 2002, StartDate: '1945-04-13T00:00:00', EndDate: '1946-04-12T00:00:00' },
{ NYear: 2003, StartDate: '1946-04-13T00:00:00', EndDate: '1947-04-13T00:00:00' },
{ NYear: 2004, StartDate: '1947-04-14T00:00:00', EndDate: '1948-04-12T00:00:00' },
{ NYear: 2005, StartDate: '1948-04-13T00:00:00', EndDate: '1949-04-12T00:00:00' },
{ NYear: 2006, StartDate: '1949-04-13T00:00:00', EndDate: '1950-04-12T00:00:00' },
{ NYear: 2007, StartDate: '1950-04-13T00:00:00', EndDate: '1951-04-13T00:00:00' },
{ NYear: 2008, StartDate: '1951-04-14T00:00:00', EndDate: '1952-04-12T00:00:00' },
{ NYear: 2009, StartDate: '1952-04-13T00:00:00', EndDate: '1953-04-12T00:00:00' },
{ NYear: 2010, StartDate: '1953-04-13T00:00:00', EndDate: '1954-04-12T00:00:00' },
{ NYear: 2011, StartDate: '1954-04-13T00:00:00', EndDate: '1955-04-13T00:00:00' },
{ NYear: 2012, StartDate: '1955-04-14T00:00:00', EndDate: '1956-04-12T00:00:00' },
{ NYear: 2013, StartDate: '1956-04-13T00:00:00', EndDate: '1957-04-12T00:00:00' },
{ NYear: 2014, StartDate: '1957-04-13T00:00:00', EndDate: '1958-04-12T00:00:00' },
{ NYear: 2015, StartDate: '1958-04-13T00:00:00', EndDate: '1959-04-13T00:00:00' },
{ NYear: 2016, StartDate: '1959-04-14T00:00:00', EndDate: '1960-04-12T00:00:00' },
{ NYear: 2017, StartDate: '1960-04-13T00:00:00', EndDate: '1961-04-12T00:00:00' },
{ NYear: 2018, StartDate: '1961-04-13T00:00:00', EndDate: '1962-04-12T00:00:00' },
{ NYear: 2019, StartDate: '1962-04-13T00:00:00', EndDate: '1963-04-13T00:00:00' },
{ NYear: 2020, StartDate: '1963-04-14T00:00:00', EndDate: '1964-04-12T00:00:00' },
{ NYear: 2021, StartDate: '1964-04-13T00:00:00', EndDate: '1965-04-12T00:00:00' },
{ NYear: 2022, StartDate: '1965-04-13T00:00:00', EndDate: '1966-04-12T00:00:00' },
{ NYear: 2023, StartDate: '1966-04-13T00:00:00', EndDate: '1967-04-13T00:00:00' },
{ NYear: 2024, StartDate: '1967-04-14T00:00:00', EndDate: '1968-04-12T00:00:00' },
{ NYear: 2025, StartDate: '1968-04-13T00:00:00', EndDate: '1969-04-12T00:00:00' },
{ NYear: 2026, StartDate: '1969-04-13T00:00:00', EndDate: '1970-04-13T00:00:00' },
{ NYear: 2027, StartDate: '1970-04-14T00:00:00', EndDate: '1971-04-13T00:00:00' },
{ NYear: 2028, StartDate: '1971-04-14T00:00:00', EndDate: '1972-04-12T00:00:00' },
{ NYear: 2029, StartDate: '1972-04-13T00:00:00', EndDate: '1973-04-12T00:00:00' },
{ NYear: 2030, StartDate: '1973-04-13T00:00:00', EndDate: '1974-04-13T00:00:00' },
{ NYear: 2031, StartDate: '1974-04-14T00:00:00', EndDate: '1975-04-13T00:00:00' },
{ NYear: 2032, StartDate: '1975-04-14T00:00:00', EndDate: '1976-04-12T00:00:00' },
{ NYear: 2033, StartDate: '1976-04-13T00:00:00', EndDate: '1977-04-12T00:00:00' },
{ NYear: 2034, StartDate: '1977-04-13T00:00:00', EndDate: '1978-04-13T00:00:00' },
{ NYear: 2035, StartDate: '1978-04-14T00:00:00', EndDate: '1979-04-13T00:00:00' },
{ NYear: 2036, StartDate: '1979-04-14T00:00:00', EndDate: '1980-04-12T00:00:00' },
{ NYear: 2037, StartDate: '1980-04-13T00:00:00', EndDate: '1981-04-12T00:00:00' },
{ NYear: 2038, StartDate: '1981-04-13T00:00:00', EndDate: '1982-04-13T00:00:00' },
{ NYear: 2039, StartDate: '1982-04-14T00:00:00', EndDate: '1983-04-13T00:00:00' },
{ NYear: 2040, StartDate: '1983-04-14T00:00:00', EndDate: '1984-04-12T00:00:00' },
{ NYear: 2041, StartDate: '1984-04-13T00:00:00', EndDate: '1985-04-12T00:00:00' },
{ NYear: 2042, StartDate: '1985-04-13T00:00:00', EndDate: '1986-04-13T00:00:00' },
{ NYear: 2043, StartDate: '1986-04-14T00:00:00', EndDate: '1987-04-13T00:00:00' },
{ NYear: 2044, StartDate: '1987-04-14T00:00:00', EndDate: '1988-04-12T00:00:00' },
{ NYear: 2045, StartDate: '1988-04-13T00:00:00', EndDate: '1989-04-12T00:00:00' },
{ NYear: 2046, StartDate: '1989-04-13T00:00:00', EndDate: '1990-04-13T00:00:00' },
{ NYear: 2047, StartDate: '1990-04-14T00:00:00', EndDate: '1991-04-13T00:00:00' },
{ NYear: 2048, StartDate: '1991-04-14T00:00:00', EndDate: '1992-04-12T00:00:00' },
{ NYear: 2049, StartDate: '1992-04-13T00:00:00', EndDate: '1993-04-12T00:00:00' },
{ NYear: 2050, StartDate: '1993-04-13T00:00:00', EndDate: '1994-04-13T00:00:00' },
{ NYear: 2051, StartDate: '1994-04-14T00:00:00', EndDate: '1995-04-13T00:00:00' },
{ NYear: 2052, StartDate: '1995-04-14T00:00:00', EndDate: '1996-04-12T00:00:00' },
{ NYear: 2053, StartDate: '1996-04-13T00:00:00', EndDate: '1997-04-12T00:00:00' },
{ NYear: 2054, StartDate: '1997-04-13T00:00:00', EndDate: '1998-04-13T00:00:00' },
{ NYear: 2055, StartDate: '1998-04-14T00:00:00', EndDate: '1999-04-13T00:00:00' },
{ NYear: 2056, StartDate: '1999-04-14T00:00:00', EndDate: '2000-04-12T00:00:00' },
{ NYear: 2057, StartDate: '2000-04-13T00:00:00', EndDate: '2001-04-13T00:00:00' },
{ NYear: 2058, StartDate: '2001-04-14T00:00:00', EndDate: '2002-04-13T00:00:00' },
{ NYear: 2059, StartDate: '2002-04-14T00:00:00', EndDate: '2003-04-13T00:00:00' },
{ NYear: 2060, StartDate: '2003-04-14T00:00:00', EndDate: '2004-04-12T00:00:00' },
{ NYear: 2061, StartDate: '2004-04-13T00:00:00', EndDate: '2005-04-13T00:00:00' },
{ NYear: 2062, StartDate: '2005-04-14T00:00:00', EndDate: '2006-04-13T00:00:00' },
{ NYear: 2063, StartDate: '2006-04-14T00:00:00', EndDate: '2007-04-13T00:00:00' },
{ NYear: 2064, StartDate: '2007-04-14T00:00:00', EndDate: '2008-04-12T00:00:00' },
{ NYear: 2065, StartDate: '2008-04-13T00:00:00', EndDate: '2009-04-13T00:00:00' },
{ NYear: 2066, StartDate: '2009-04-14T00:00:00', EndDate: '2010-04-13T00:00:00' },
{ NYear: 2067, StartDate: '2010-04-14T00:00:00', EndDate: '2011-04-13T00:00:00' },
{ NYear: 2068, StartDate: '2011-04-14T00:00:00', EndDate: '2012-04-12T00:00:00' },
{ NYear: 2069, StartDate: '2012-04-13T00:00:00', EndDate: '2013-04-13T00:00:00' },
{ NYear: 2070, StartDate: '2013-04-14T00:00:00', EndDate: '2014-04-13T00:00:00' },
{ NYear: 2071, StartDate: '2014-04-14T00:00:00', EndDate: '2015-04-13T00:00:00' },
{ NYear: 2072, StartDate: '2015-04-14T00:00:00', EndDate: '2016-04-12T00:00:00' },
{ NYear: 2073, StartDate: '2016-04-13T00:00:00', EndDate: '2017-04-13T00:00:00' },
{ NYear: 2074, StartDate: '2017-04-14T00:00:00', EndDate: '2018-04-13T00:00:00' },
{ NYear: 2075, StartDate: '2018-04-14T00:00:00', EndDate: '2019-04-13T00:00:00' },
{ NYear: 2076, StartDate: '2019-04-14T00:00:00', EndDate: '2020-04-12T00:00:00' },
{ NYear: 2077, StartDate: '2020-04-13T00:00:00', EndDate: '2021-04-13T00:00:00' },
{ NYear: 2078, StartDate: '2021-04-14T00:00:00', EndDate: '2022-04-13T00:00:00' },
{ NYear: 2079, StartDate: '2022-04-14T00:00:00', EndDate: '2023-04-13T00:00:00' },
{ NYear: 2080, StartDate: '2023-04-14T00:00:00', EndDate: '2024-04-12T00:00:00' },
{ NYear: 2081, StartDate: '2024-04-13T00:00:00', EndDate: '2025-04-13T00:00:00' },
{ NYear: 2082, StartDate: '2025-04-14T00:00:00', EndDate: '2026-04-13T00:00:00' },
{ NYear: 2083, StartDate: '2026-04-14T00:00:00', EndDate: '2027-04-13T00:00:00' },
{ NYear: 2084, StartDate: '2027-04-14T00:00:00', EndDate: '2028-04-12T00:00:00' },
{ NYear: 2085, StartDate: '2028-04-13T00:00:00', EndDate: '2029-04-13T00:00:00' },
{ NYear: 2086, StartDate: '2029-04-14T00:00:00', EndDate: '2030-04-13T00:00:00' },
{ NYear: 2087, StartDate: '2030-04-14T00:00:00', EndDate: '2031-04-14T00:00:00' },
{ NYear: 2088, StartDate: '2031-04-15T00:00:00', EndDate: '2032-04-13T00:00:00' },
{ NYear: 2089, StartDate: '2032-04-14T00:00:00', EndDate: '2033-04-13T00:00:00' },
{ NYear: 2090, StartDate: '2033-04-14T00:00:00', EndDate: '2034-04-13T00:00:00' },
{ NYear: 2091, StartDate: '2034-04-14T00:00:00', EndDate: '2035-04-13T00:00:00' },
{ NYear: 2092, StartDate: '2035-04-14T00:00:00', EndDate: '2036-04-13T00:00:00' },
{ NYear: 2093, StartDate: '2036-04-14T00:00:00', EndDate: '2037-04-13T00:00:00' },
{ NYear: 2094, StartDate: '2037-04-14T00:00:00', EndDate: '2038-04-13T00:00:00' },
{ NYear: 2095, StartDate: '2038-04-14T00:00:00', EndDate: '2039-04-13T00:00:00' },
{ NYear: 2096, StartDate: '2039-04-14T00:00:00', EndDate: '2040-04-13T00:00:00' },
{ NYear: 2097, StartDate: '2040-04-14T00:00:00', EndDate: '2041-04-13T00:00:00' },
{ NYear: 2098, StartDate: '2041-04-14T00:00:00', EndDate: '2042-04-13T00:00:00' },
{ NYear: 2099, StartDate: '2042-04-14T00:00:00', EndDate: '2043-04-13T00:00:00' },
{ NYear: 2100, StartDate: '2043-04-14T00:00:00', EndDate: '2044-04-13T00:00:00' },
{ NYear: 2101, StartDate: '2044-04-14T00:00:00', EndDate: '2045-04-13T00:00:00' },
{ NYear: 2102, StartDate: '2045-04-14T00:00:00', EndDate: '2046-04-13T00:00:00' },
{ NYear: 2103, StartDate: '2046-04-14T00:00:00', EndDate: '2047-04-13T00:00:00' },
{ NYear: 2104, StartDate: '2047-04-14T00:00:00', EndDate: '2048-04-13T00:00:00' },
{ NYear: 2105, StartDate: '2048-04-14T00:00:00', EndDate: '2049-04-14T00:00:00' },
{ NYear: 2106, StartDate: '2049-04-15T00:00:00', EndDate: '2050-04-14T00:00:00' },
{ NYear: 2107, StartDate: '2050-04-15T00:00:00', EndDate: '2051-04-14T00:00:00' },
{ NYear: 2108, StartDate: '2051-04-15T00:00:00', EndDate: '2052-04-14T00:00:00' },
{ NYear: 2109, StartDate: '2052-04-15T00:00:00', EndDate: '2053-04-14T00:00:00' },
{ NYear: 2110, StartDate: '2053-04-15T00:00:00', EndDate: '2054-04-14T00:00:00' },
{ NYear: 2111, StartDate: '2054-04-15T00:00:00', EndDate: '2055-04-14T00:00:00' }];
class CalendarService {
constructor() { }
GetBSMonthList() {
const monthList = [
{ month: 'बैशाख', id: 1 },
{ month: 'जेष्ठ', id: 2 },
{ month: 'असार', id: 3 },
{ month: 'श्रावण', id: 4 },
{ month: 'भाद्र', id: 5 },
{ month: 'आश्विन', id: 6 },
{ month: 'कार्तिक', id: 7 },
{ month: 'मंसीर', id: 8 },
{ month: 'पुष', id: 9 },
{ month: 'माघ', id: 10 },
{ month: 'फाल्गुन', id: 11 },
{ month: 'चैत्र', id: 12 }
];
return monthList;
}
getFiscalYear(date) {
const bsDate = this.GetDateBS(date, DateFormat.MMddyyyy);
const bsMonth = this.GetBSMonth(bsDate, DateFormat.MMddyyyy);
const bsYear = this.GetBSYear(bsDate, DateFormat.MMddyyyy);
let result;
if (bsMonth <= 3) {
result = (bsYear - 1).toString().substring(2) + '।' + bsYear.toString().substring(2);
}
else {
result = bsYear.toString().substring(2) + '।' + (bsYear + 1).toString().substring(2);
}
return result;
}
GetADMonthList() {
const monthList = [
{ month: 'January', id: 1 },
{ month: 'February', id: 2 },
{ month: 'March', id: 3 },
{ month: 'April', id: 4 },
{ month: 'May', id: 5 },
{ month: 'June', id: 6 },
{ month: 'July', id: 7 },
{ month: 'August', id: 8 },
{ month: 'September', id: 9 },
{ month: 'October', id: 10 },
{ month: 'November', id: 11 },
{ month: 'December', id: 12 }
];
return monthList;
}
GetBSMonthName(monthId) {
const monthname = this.GetBSMonthList().filter(x => x.id === monthId);
if (monthname.length > 0) {
return monthname[0].month;
}
else {
return null;
}
}
GetADMonthName(monthId) {
const monthname = this.GetADMonthList().filter(x => x.id === monthId);
if (monthname.length > 0) {
return monthname[0].month;
}
else {
return null;
}
}
GetWeekDayName(dayId) {
const weekDay = this.GetWeekDayNameList().filter(x => x.id === dayId);
if (weekDay.length > 0) {
return weekDay[0].day;
}
else {
return null;
}
}
GetWeekDayNameList() {
const dayList = [
{ day: 'Sunday', nepaliDay: 'आइतबार', id: 1, prefix: 'Sun' },
{ day: 'Monday', nepaliDay: 'साेमबार', id: 2, prefix: "Mon" },
{ day: 'Tuesday', nepaliDay: 'मंगलबार', id: 3, prefix: "Tue" },
{ day: 'Wednesday', nepaliDay: 'बुधबार', id: 4, prefix: "Wed" },
{ day: 'Thursday', nepaliDay: 'बिहिबार', id: 5, prefix: "Thu" },
{ day: 'Friday', nepaliDay: 'शुक्रबार', id: 6, prefix: "Fri" },
{ day: 'Saturday', nepaliDay: 'शनिबार', id: 7, prefix: "Sat" },
];
return dayList;
}
GetWeekDayPrefixList() {
const dayList = [
{ day: 'Su', nepaliDay: 'आ.', id: 1, prefix: 'Sun' },
{ day: 'Mo', nepaliDay: 'साे.', id: 2, prefix: 'Mon' },
{ day: 'Tu', nepaliDay: 'मं.', id: 3, prefix: "Tue" },
{ day: 'We', nepaliDay: 'बु.', id: 4, prefix: "Wed" },
{ day: 'Th', nepaliDay: 'बि.', id: 5, prefix: "Thu" },
{ day: 'Fr', nepaliDay: 'शु.', id: 6, prefix: "Fri" },
{ day: 'Sa', nepaliDay: 'श.', id: 7, prefix: "Sat" },
];
return dayList;
}
GetBSYearCal(NYear) {
const bsMonthList = [];
const selectedNDateD = NDateD.filter(x => x.NYear === NYear)[0];
let days = 0;
days = days + selectedNDateD.M1;
bsMonthList.push({ Month: 1, Days: days });
days = days + selectedNDateD.M2;
bsMonthList.push({ Month: 2, Days: days });
days = days + selectedNDateD.M3;
bsMonthList.push({ Month: 3, Days: days });
days = days + selectedNDateD.M4;
bsMonthList.push({ Month: 4, Days: days });
days = days + selectedNDateD.M5;
bsMonthList.push({ Month: 5, Days: days });
days = days + selectedNDateD.M6;
bsMonthList.push({ Month: 6, Days: days });
days = days + selectedNDateD.M7;
bsMonthList.push({ Month: 7, Days: days });
days = days + selectedNDateD.M8;
bsMonthList.push({ Month: 8, Days: days });
days = days + selectedNDateD.M9;
bsMonthList.push({ Month: 9, Days: days });
days = days + selectedNDateD.M10;
bsMonthList.push({ Month: 10, Days: days });
days = days + selectedNDateD.M11;
bsMonthList.push({ Month: 11, Days: days });
days = days + selectedNDateD.M12;
bsMonthList.push({ Month: 12, Days: days });
return bsMonthList;
}
GetBSDay(bsDate, df) {
let result;
const bsDateArray = bsDate.split('-');
switch (df) {
case 'ddMMyyyy': // ddmmyyyy
result = Number(bsDateArray[0]);
break;
case 'MMddyyyy': // mmddyyyy
result = Number(bsDateArray[1]);
break;
case 'yyyyddMM': // yyyyddmm
result = Number(bsDateArray[1]);
break;
case 'yyyyMMdd': // yyyymmdd
result = Number(bsDateArray[2]);
break;
}
return result;
}
GetBSMonth(bsDate, df) {
let result;
const bsDateArray = bsDate.split('-');
switch (df) {
case 'ddMMyyyy': // ddmmyyyy
result = Number(bsDateArray[1]);
break;
case 'MMddyyyy': // mmddyyyy
result = Number(bsDateArray[0]);
break;
case 'yyyyddMM': // yyyyddmm
result = Number(bsDateArray[2]);
break;
case 'yyyyMMdd': // yyyymmdd
result = Number(bsDateArray[1]);
break;
}
return result;
}
GetBSYear(bsDate, df) {
let result;
const NDateArray = bsDate.split('-');
switch (df) {
case 'ddMMyyyy': // ddmmyyyy
result = Number(NDateArray[2]);
break;
case 'MMddyyyy': // mmddyyyy
result = Number(NDateArray[2]);
break;
case 'yyyyddMM': // yyyyddmm
result = Number(NDateArray[0]);
break;
case 'yyyyMMdd': // yyyymmdd
result = Number(NDateArray[0]);
break;
}
return result;
}
GetMaxYear() {
return Math.max.apply(Math, BSADCal.map(o => o.NYear));
}
GetMinYear() {
return Math.min.apply(Math, BSADCal.map(o => o.NYear));
}
GetDateBS(adDate, df) {
if (!adDate) {
return null;
}
adDate = new Date(adDate);
let startDate;
let bsYear;
let bsMonth;
let bsDay;
adDate = new Date(adDate.getFullYear(), adDate.getMonth(), adDate.getDate());
try {
startDate = new Date(BSADCal.filter(x => new Date(x.EndDate) >= adDate && new Date(x.StartDate) <= adDate)[0].StartDate);
bsYear = BSADCal.filter(x => new Date(x.EndDate) >= adDate && new Date(x.StartDate) <= adDate)[0].NYear;
const totalDays = this.GetDateDiff(adDate, startDate) + 1;
bsMonth = this.GetBSYearCal(bsYear).filter(x => x.Days >= totalDays)[0].Month;
const dyList = this.GetBSYearCal(bsYear).filter(x => x.Days < totalDays).reverse()[0];
if (dyList) {
bsDay = dyList.Days;
}
bsDay = totalDays - (bsDay === undefined ? 0 : bsDay);
}
catch (e) {
return null;
}
return this.GetFormatedDateBS(bsYear, bsMonth, bsDay, df);
}
GetDateAD(bsYear, bsMonth, bsDay) {
let adDate = new Date();
let totalDays = 0;
const ndateD = NDateD.filter(x => x.NYear === bsYear);
if (ndateD.length === 0) {
return null;
}
if (bsMonth < 1 || bsMonth > 12) {
return null;
}
if (this.GetDaysInMonthBS(bsYear, bsMonth) < bsDay) {
return null;
}
adDate = new Date(BSADCal.filter(x => x.NYear === bsYear)[0].StartDate);
const listMonth = this.GetBSYearCal(bsYear).filter(x => x.Month < bsMonth);
totalDays = listMonth.length > 0 ? listMonth.reverse()[0].Days : 0;
totalDays = totalDays ? totalDays : 0;
totalDays = totalDays + bsDay - 1;
totalDays = (totalDays * 24 * 3600 * 1000);
totalDays += adDate.getTime();
adDate.setTime(totalDays);
return adDate;
}
GetDateADByDateBS(bsDate, df) {
let adDate;
let totalDays = 0;
const bsYear = this.GetBSYear(bsDate, df);
const bsMonth = this.GetBSYear(bsDate, df);
const bsDay = this.GetBSYear(bsDate, df);
if (NDateD.filter(x => x.NYear).length === 0 &&
bsMonth < 1 && bsMonth > 12 &&
this.GetDaysInMonthBS(bsYear, bsMonth) < bsDay) {
return null;
}
adDate = new Date(BSADCal.filter(x => x.NYear === bsYear)[0].StartDate);
totalDays = this.GetBSYearCal(bsYear).filter(x => x.Month === bsMonth)[0].Days;
totalDays = totalDays + bsDay - 1;
totalDays = (totalDays * 24 * 3600 * 1000);
totalDays += adDate.getTime();
adDate.setTime(totalDays);
return adDate;
}
GetDateADOfMonthStartEnd(bsDate, isStart, df) {
const bsYear = this.GetBSYear(bsDate, df);
const bsMonth = this.GetBSMonth(bsDate, df);
const bsDay = this.GetBSDay(bsDate, df);
let daysInMonth = 0;
let adDate = new Date();
if (isStart) {
adDate = this.GetDateAD(bsDay, bsMonth, 1);
}
else {
daysInMonth = this.GetDaysInMonthBS(bsYear, bsMonth);
adDate = this.GetDateAD(bsYear, bsMonth, daysInMonth);
}
return adDate;
}
GetDaysInMonthBS(bsYear, bsMonth) {
switch (bsMonth) {
case 1:
return NDateD.filter(x => x.NYear === bsYear)[0].M1;
case 2:
return NDateD.filter(x => x.NYear === bsYear)[0].M2;
case 3:
return NDateD.filter(x => x.NYear === bsYear)[0].M3;
case 4:
return NDateD.filter(x => x.NYear === bsYear)[0].M4;
case 5:
return NDateD.filter(x => x.NYear === bsYear)[0].M5;
case 6:
return NDateD.filter(x => x.NYear === bsYear)[0].M6;
case 7:
return NDateD.filter(x => x.NYear === bsYear)[0].M7;
case 8:
return NDateD.filter(x => x.NYear === bsYear)[0].M8;
case 9:
return NDateD.filter(x => x.NYear === bsYear)[0].M9;
case 10:
return NDateD.filter(x => x.NYear === bsYear)[0].M10;
case 11:
return NDateD.filter(x => x.NYear === bsYear)[0].M11;
case 12:
return NDateD.filter(x => x.NYear === bsYear)[0].M12;
default:
return 0;
}
}
GetDaysInMonthAD(adYear, adMonth) {
let daysInMonth;
const adDate = new Date(adYear, adMonth, 1);
const date1 = adDate;
date1.setDate(1 - date1.getDate());
const date2 = adDate;
date2.setDate(1 - date2.getDate());
daysInMonth = (1 + this.GetDateAdd(date2, adDate)) - this.GetDateAdd(date1, adDate);
return daysInMonth;
}
getFormatedDate(dateAD, option) {
let result;
if (option.userSelectedFormat) {
if (option.userSelectedFormat === 1) {
option.dtFormat = DateFormat.ddMMyyyy;
}
else if (option.userSelectedFormat === 2) {
option.dtFormat = DateFormat.MMddyyyy;
}
else if (option.userSelectedFormat === 3) {
option.dtFormat = DateFormat.yyyyMMdd;
}
else if (option.userSelectedFormat === 4) {
option.dtFormat = DateFormat.yyyyddMM;
}
}
if (!option.dtFormat) {
option.dtFormat = DateFormat.ddMMyyyy;
}
if (!option.dateType) {
option.dateType = DateType.AD;
}
if (dateAD) {
if (option.dateType === DateType.AD) {
result = this.GetFormatedDateAD(dateAD, option.dtFormat);
}
else {
result = this.GetDateBS(dateAD, option.dtFormat);
}
}
else {
result = 'undefined';
}
return result;
}
GetFormatedDateAD(adDate, dtFormat) {
adDate = new Date(adDate);
// console.log(adDate)
const yy = adDate.getFullYear().toString();
const mm = (adDate.getMonth() + 1 < 10) ? '0' + (adDate.getMonth() + 1).toString() : (adDate.getMonth() + 1).toString();
const dd = (adDate.getDate() < 10) ? '0' + (adDate.getDate()).toString() : (adDate.getDate()).toString();
switch (dtFormat) {
case 'ddMMyyyy':
return dd + '-' + mm + '-' + yy;
case 'MMddyyyy':
return mm + '-' + dd + '-' + yy;
case 'yyyyddMM': // yyyyddmm
return yy + '-' + dd + '-' + mm;
case 'yyyyMMdd': // yyyymmdd
return yy + '-' + mm + '-' + dd;
default: // ddmmyyyy
return dd + '-' + mm + '-' + yy;
}
}
GetFormatedDateBS(bsYear, bsMonth, bsDay, dtFormat) {
const yy = bsYear.toString();
const mm = (bsMonth < 10) ? '0' + bsMonth : bsMonth.toString();
const dd = (bsDay < 10) ? '0' + bsDay : bsDay.toString();
switch (dtFormat) {
case 'ddMMyyyy':
return dd + '-' + mm + '-' + yy;
case 'MMddyyyy':
return mm + '-' + dd + '-' + yy;
case 'yyyyddMM': // yyyyddmm
return yy + '-' + dd + '-' + mm;
case 'yyyyMMdd': // yyyymmdd
return yy + '-' + mm + '-' + dd;
default: // ddmmyyyy
return dd + '-' + mm + '-' + yy;
}
}
getFormatedDateLong(value, dtFormat, dtType) {
if (value && value.length == 10) {
value = value.substr(0, 10);
const yr = this.GetBSYear(value, dtFormat);
const mn = this.GetBSMonth(value, dtFormat);
const dy = this.GetBSDay(value, dtFormat);
let monthName = '';
if (dtType === DateType.BS) {
const monthList = this.GetBSMonthList();
monthName = monthList[mn - 1].month;
}
else {
const monthList = this.GetADMonthList();
monthName = monthList[mn - 1].month;
}
return `${dy} ${monthName} ${yr}`;
}
else {
return `Calendar not found!`;
}
}
getLongDateString(val) {
const date = new Date(val.getFullYear(), val.getMonth(), val.getDate(), val.getHours(), val.getMinutes(), val.getSeconds());
var result = `${this.GetWeekDayPrefixList()[date.getDay()].prefix}, ${this.GetADMonthList()[date.getMonth()].month} ${date.getDate()} ${date.getFullYear()}`;
return result;
}
GetDaysInYear(bsYear) {
let totalDays = 0;
NDateD.filter(x => x.NYear < bsYear).forEach(item => {
totalDays += item.M1 + item.M2 + item.M3 + item.M4 + item.M5 + item.M6;
totalDays += item.M7 + item.M8 + item.M9 + item.M10 + item.M11 + item.M12;
});
return totalDays;
}
GetDateAdd(date1, date2) {
const timeAdd = date2.getTime() + date1.getTime();
return Math.ceil(Math.abs(timeAdd / (1000 * 3600 * 24)));
}
GetDateDiff(date1, date2) {
const timeDiff = date2.getTime() - date1.getTime();
return Math.ceil(Math.abs(timeDiff / (1000 * 3600 * 24)));
}
addYearInBS(bsDate, addYear, df) {
let year = this.GetBSYear(bsDate, df);
let month = this.GetBSMonth(bsDate, df);
let day = this.GetBSDay(bsDate, df);
const oldDaysInMonth = this.GetDaysInMonthBS(year, month);
year = year + addYear;
if (day === 1) {
if (month === 1) {
month = 12;
year = year - 1;
}
else {
month = month - 1;
}
day = this.GetDaysInMonthBS(year, month);
}
else {
if (oldDaysInMonth === day) {
day = this.GetDaysInMonthBS(year, month) - 1;
}
else {
day = day - 1;
if (day >= this.GetDaysInMonthBS(year, month)) {
day = this.GetDaysInMonthBS(year, month) - 1;
}
}
}
return this.GetDateAD(year, month, day);
}
}
CalendarService.decorators = [
{ type: Injectable }
];
CalendarService.ctorParameters = () => [];
class CalendarErrorStateMatcher {
isErrorState(control, form) {
if (control.value && control.value.toString().includes("_")) {
return true;
}
const isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
}
}
const label = {
BSCalendar: ['BS Calendar', 'नेपाली क्यालेन्डर'],
ADCalendar: ['AD Calendar', 'अङ्ग्रेजी क्यालेन्डर'],
BSDate: ['BS Date', 'गते'],
ADDate: ['AD Date', 'मिति'],
AD: ['AD', 'मिति'],
BS: ['BS', 'गते'],
switchToAD: ['Click to get AD Date', 'मिति हेर्न थिचनुहाेस'],
switchToBS: ['Click to get BS Date', 'गते हेर्न थिच्नुहाेस'],
showBSCalendar: ['Click to get Nepali Calendar', 'नेपाली क्यालेन्डर हेर्न थिच्नुहाेस'],
showADCalendar: ['Click to get AD Calendar', 'अङ्ग्रेजी क्यालेन्डर हेर्न थिच्नुहाेस'],
clearTooltip: ['Clear This data', 'मेट्नुहाेस'],
dateRequiredLabel: [' is required', ' अावस्यक छ।'],
invalidMessage: ['Invalid date!', 'गते/मिति मिलेन!'],
startingBSDateError: ['BS Calendar not match for starting date!', 'शुरू गते नेपाली क्यालेनडरमा मिलेन'],
endingBSDateError: ['BS Calendar not match for end date!', 'अन्तिम गते नेपाली क्यालेनडरमा मिलेन'],
fromDateToDateNotMatch: ['End date cannot be less than starting date!', 'अन्तिम गते शुरू गते भन्दा कम हुनु भएन।']
};
const moment = moment_;
class DateComponent {
constructor(dpService, snackbar, controlDir) {
this.dpService = dpService;
this.snackbar = snackbar;
this.controlDir = controlDir;
this.onDateChanged = new EventEmitter();
this.matcher = new CalendarErrorStateMatcher();
this.dateFormat = DateFormat.ddMMyyyy;
this.datemask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
this.stateChanges = new Subject();
///////////////////////////////////////////
this.changeDateTooltip = 'Toggle Date Type';
this.showCalendarTooltip = 'Show Calendar';
this.clearTooltip = 'Clear date';
this.errorMessage = '';
this.isPickerVisible = false;
this.dateObject = [];
///////////////////////////////////////////////
// private _dateType: DateType = DateType.AD;
// private _dateFormatAD: DateFormat = DateFormat.ddMMyyyy;
// private _dateFormatBS: DateFormat = DateFormat.yyyyMMdd;
this._withTime = false;
this._placeholder = "Date";
this._readonly = false;
this._closeOnClick = true;
this._isRange = false;
this._language = 0;
this._required = false;
this.lastEmitted = null;
this.manualChanged = true;
this._param = { dateType: DateType.AD, dateFormatAD: DateFormat.ddMMyyyy, dateFormatBS: DateFormat.yyyyMMdd };
this.propagateChange = (_) => {
};
this.onTouched = () => { };
this.onBlur = (event) => {
if (event.target.value === "" || event.target.value.toString().includes("_")) {
this.setDateValueByString(event.target.value, this.dateFormat, this._param.dateType);
}
};
this.formControl = new FormControl();
controlDir.valueAccessor = this;
this.caption = label;
}
set param(val) {
this._param = JSON.parse(val);
this.changeDateFormat(this._param.dateType, this._param.dateType === DateType.AD ? this._param.dateFormatAD : this._param.dateFormatBS);
this.setValue(false, false);
}
get param() {
return this._param;
}
// @Input() set dateType(val: DateType) {
// this._dateType = val;
// console.log(this._dateType, "datet")
// this.changeDateFormat(val);
// } get dateType(): DateType {
// return this._dateType;
// }
// @Input() set dateFormatAD(val: DateFormat) {
// this._dateFormatAD = val;
// } get dateFormatAD(): DateFormat {
// return this._dateFormatAD;
// }
// @Input() set dateFormatBS(val: DateFormat) {
// this._dateFormatBS = val;
// } get dateFormatBS(): DateFormat {
// return this._dateFormatBS;
// }
set required(val) {
this._required = coerceBooleanProperty(val);
}
get required() {
return this._required;
}
pushTimeMask(mask) {
mask.push(' ');
mask.push(/\d/);
mask.push(/\d/);
mask.push(':');
mask.push(/\d/);
mask.push(/\d/);
return mask;
}
changeDateFormat(dType, val) {
if (!val) {
if (dType === DateType.AD) {
val = this._param.dateFormatAD;
}
else {
val = this._param.dateFormatBS;
}
}
let mask;
if (dType === DateType.AD) {
if (val === DateFormat.MMddyyyy || val === DateFormat.ddMMyyyy) {
mask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
else {
mask = [/\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/];
}
}
else {
if (val === DateFormat.MMddyyyy || val === DateFormat.ddMMyyyy) {
mask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
else {
mask = [/\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/];
}
}
if (this.withTime) {
mask = this.pushTimeMask(mask);
}
if (this.isRange) {
const mask1 = [...mask];
const mask2 = [...mask];
const seperator = [' ', '|', ' '];
this.datemask = [...mask1, ...seperator, ...mask2];
}
else {
this.datemask = [...mask];
}
this.dateFormat = val;
}
set withTime(val) {
this._withTime = coerceBooleanProperty(val);
}
get withTime() {
return this._withTime;
}
set placeholder(val) {
this._placeholder = val;
}
get placeholder() {
return this._placeholder;
}
// @Input() set showCalendarOnFocus(val: boolean) {
// this._showCalendarOnFocus = val;
// } get showCalendarOnFocus(): boolean {
// return this._showCalendarOnFocus;
// }
set readonly(val) {
this._readonly = coerceBooleanProperty(val);
}
get readonly() {
return this._readonly;
}
set closeOnClick(val) {
this._closeOnClick = coerceBooleanProperty(val);
}
get closeOnClick() {
return this._closeOnClick;
}
set disabled(val) {
this.setDisabledState(coerceBooleanProperty(val));
}
get disabled() {
return this.formControl.disabled;
}
set isRange(val) {
this._isRange = coerceBooleanProperty(val);
this.changeDateFormat(this._param.dateType);
}
get isRange() {
return this._isRange;
}
set language(val) {
this._language = val;
}
get language() {
return this._language;
}
// private _object: any;
// @Input() set object(val: any) {
// console.log(val)
// this._object = val;
// } get object(): any {
// return this._object;
// }
// ngDoCheck() {
// if(this.object){
// if(!this.object.equals(this._object)) {
// // inputSettings changed
// // some logic here to react to the change
// this._object = this.object;
// }
// }
// }
//start controlValueAccsor
registerOnChange(fn) {
this.propagateChange = fn;
}
writeValue(value) {
// const val = new Date(value);
this.dateObject = [];
this.manualChanged = true;
this.setDateValueByDate(value);
this.formControl.markAsUntouched();
}
registerOnTouched(fn) {
this.onTouched = fn;
}
setDisabledState(isDisabled) {
if (isDisabled) {
this.formControl.disable();
}
else {
this.formControl.enable();
}
}
//end controlValueAccsor
setDateValueByDate(value) {
// let date = value;
if (!value) {
this.setValue(true, true);
return;
}
let timeString = "";
let h, m;
const FORMAT_DATE = moment.defaultFormat;
this.changeDateFormat(this._param.dateType);
if (this.isRange) {
let formatedStartDateAD = '';
let formatedStartDateBS = '';
let formatedEndDateAD = '';
let formatedEndDateBS = '';
if (value && value.start) {
const startDate = moment(value.start, FORMAT_DATE);
const endDate = moment(value.end, FORMAT_DATE);
if (startDate.isValid()) {
h = startDate.hour();
m = startDate.minute();
timeString = h > 9 ? `${h}:` : `0${h}:`;
timeString = timeString + (m > 9 ? `${m}` : `0${m}`);
formatedStartDateAD = this.dpService.GetFormatedDateAD(value.start, this._param.dateFormatAD);
formatedStartDateBS = this.dpService.GetDateBS(value.start, this._param.dateFormatBS);
if (this.withTime) {
formatedStartDateAD = `${formatedStartDateAD} ${timeString}`;
formatedStartDateBS = `${formatedStartDateBS} ${timeString}`;
}
}
if (endDate.isValid()) {
h = endDate.hour();
m = endDate.minute();
timeString = h > 9 ? `${h}:` : `0${h}:`;
timeString = timeString + (m > 9 ? `${m}` : `0${m}`);
formatedEndDateAD = this.dpService.GetFormatedDateAD(value.end, this._param.dateFormatAD);
formatedEndDateBS = this.dpService.GetDateBS(value.end, this._param.dateFormatBS);
if (this.withTime) {
formatedEndDateAD = `${formatedStartDateAD} ${timeString}`;
formatedEndDateBS = `${formatedStartDateBS} ${timeString}`;
}
}
// if (initial === true) {
// if (this.dateType === DateType.AD) {
// this.formControl.setValue(`${formatedStartDateAD} | ${formatedEndDateAD}`);
// } else {
// this.formControl.setValue(`${formatedStartDateBS} | ${formatedEndDateBS}`);
// }
// }
this.setDateObject(0, value.start, formatedStartDateBS, formatedStartDateAD, this._param.dateType);
this.setDateObject(1, value.end, formatedEndDateBS, formatedEndDateAD, this._param.dateType);
}
}
else {
const date = moment(value, FORMAT_DATE);
if (date.isValid()) {
h = date.hour();
m = date.minute();
timeString = h > 9 ? `${h}:` : `0${h}:`;
timeString = timeString + (m > 9 ? `${m}` : `0${m}`);
const dtAD = this.withTime ? `${this.dpService.GetFormatedDateAD(value, this._param.dateFormatAD)} ${timeString}` : `${this.dpService.GetFormatedDateAD(value, this._param.dateFormatAD)}`;
const dtBS = this.withTime ? `${this.dpService.GetDateBS(value, this._param.dateFormatBS)} ${timeString}` : `${this.dpService.GetDateBS(value, this._param.dateFormatBS)}`;
this.setDateObject(0, value, dtBS, dtAD, this._param.dateType);
// if (initial === true) {
// if (this.dateType === DateType.AD) {
// this.formControl.setValue(dtAD)
// } else {
// this.formControl.setValue(dtBS)
// }
// }
}
}
this.setValue(true, true);
// this.execPropagateChange(date);
}
setDateValueByString(dtValue, dtFormat, dtType) {
if ((dtValue.toString().includes("_")) || (dtValue.toString() === "")) {
this.dateObject = [];
this.execPropagateChange(null);
return;
}
const givenArray = dtValue.split(' | ');
let loop = 0;
givenArray.forEach(element => {
const lineArray = element.split(" ");
const dateString = lineArray[0];
const splitedDate = dateString.split("-");
let timeString = "";
let yr;
let mn;
let dy;
let hr = 0;
let mu = 0;
if (dtFormat === DateFormat.MMddyyyy) {
yr = +splitedDate[2];
mn = +splitedDate[0];
dy = +splitedDate[1];
}
else if (dtFormat === DateFormat.ddMMyyyy) {
yr = +splitedDate[2];
mn = +splitedDate[1];
dy = +splitedDate[0];
}
else if (dtFormat === DateFormat.yyyyddMM) {
yr = +splitedDate[0];
mn = +splitedDate[2];
dy = +splitedDate[1];
}
else if (dtFormat === DateFormat.yyyyMMdd) {
yr = +splitedDate[0];
mn = +splitedDate[1];
dy = +splitedDate[2];
}
if (mn <= 0 || mn > 12) {
this.execPropagateChange(null);
return;
}
if (dy <= 0 || dy > 32) {
this.execPropagateChange(null);
return;
}
if (lineArray.length > 1) {
const splitedTime = lineArray[1].split(":");
hr = +splitedTime[0];
mu = +splitedTime[1];
if (hr > 23 || mu > 59) {
this.execPropagateChange(null);
if (hr > 23) {
this.errorMessage = "Hour is invalid.";
}
if (mu > 59) {
this.errorMessage = "Minute is invalid.";
}
return;
}
const strHr = (hr < 10) ? '0' + hr : hr.toString();
const strMn = (mu < 10) ? '0' + mu : mu.toString();
timeString = ` ${strHr}:${strMn}`;
}
if (dtType === DateType.AD) {
const newDate = new Date(yr, mn - 1, dy, hr, mu);
const dtAD = `${this.dpService.GetFormatedDateAD(newDate, this._param.dateFormatAD)}${timeString}`;
const dtBS = this.dpService.GetDateBS(newDate, this._param.dateFormatBS);
this.setDateObject(loop, newDate, dtBS ? `${dtBS}${timeString}` : '', dtAD, dtType);
}
else {
let newDate = this.dpService.GetDateAD(yr, mn, dy);
if (newDate === null) {
this.execPropagateChange(null);
this.errorMessage = this.language === 0 ? 'BS Calendar not match!' : 'नेपाली क्यालेन्डर अनुसार गते मिलेन।';
return;
}
else {
const dtAD = `${this.dpService.GetFormatedDateAD(newDate, this._param.dateFormatAD)}${timeString}`;
const dtBS = `${this.dpService.GetDateBS(newDate, this._param.dateFormatBS)}`;
newDate = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), hr, mu);
this.setDateObject(loop, newDate, dtBS ? `${dtBS}${timeString}` : '', dtAD, dtType);
}
}
loop++;
});
if (this.dateObject && this.dateObject.length >= 1) {
if (this.isRange) {
this.execPropagateChange({
start: this.dateObject[0].date,
end: this.dateObject[1].date
});
}
else {
this.execPropagateChange(this.dateObject[0].date);
}
}
else {
this.execPropagateChange(null);
}
}
setDateObject(index, dt, dtBS, dtAD, dtType) {
if (index === 0) {
this.dateObject = [];
}
this.dateObject.push({
date: dt,
dateAD: dtAD,
dateBS: dtBS,
selectedDateType: dtType
});
}
onManualChange(event) {
// if(this.readonly){
// return
// }
let newValue;
if (event.type === 'change' || event.type === 'paste') {
if (event.type === 'change') {
newValue = event.target.value;
}
else {
newValue = event.clipboardData.getData('Text');
}
this.setDateValueByString(newValue, this.dateFormat, this._param.dateType);
}
else if (event.type === 'keyup') {
if (event.target.value.toString().trim() === "") {
this.execPropagateChange(null);
}
else if (!event.target.value.toString().includes("_")) {
this.setDateValueByString(event.target.value, this.dateFormat, this._param.dateType);
}
else {
this.execPropagateChange(null);
}
if ((event.keyCode >= 48 && event.keyCode <= 57) || event.keyCode === 8 || event.keyCode === 46 || event.keyCode === 32) {
newValue = event.target.value;
if (this.controlDir.control.valid && this.dateObject.length > 0) {
if (!this.isRange) {
if (newValue !== (this._param.dateType === DateType.AD ? this.dateObject[0].dateAD : this.dateObject[0].dateBS)) {
this.setDateValueByString(newValue, this.dateFormat, this._param.dateType);
}
}
else {
if (newValue !== (this._param.dateType === DateType.AD ? `${this.dateObject[0].dateAD} | ${this.dateObject[1].dateAD}` : `${this.dateObject[0].dateBS} | ${this.dateObject[1].dateBS}`)) {
this.setDateValueByString(newValue, this.dateFormat, this._param.dateType);
}
}
}
}
}
else if (event.type === "keydown") {
if (event.code === "Space") {
event.stopPropagation();
event.preventDefault();
this.showPicker();
}
}
}
emitChange(withToolTip) {
//console.log(withToolTip)
if (this.formControl.value !== this.lastEmitted) {
let dateToEmit = null;
if (this.dateObject.length > 0) {
if (this.isRange) {
dateToEmit = {
start: this.dateObject[0],
end: this.dateObject[1]
};
}
else {
dateToEmit = this.dateObject[0];
}
}
else {
dateToEmit = null;
}
this.setTooltip();
if (this.manualChanged === false && withToolTip) {
this.elTooltip ? this.elTooltip.show() : undefined;
}
else {
this.manualChanged = false;
}
//
this.onDateChanged.emit(dateToEmit);
this.lastEmitted = this.formControl.value;
}
}
execPropagateChange(obj, isDateTypeChanged = false, withToolTip = true) {
if (obj === null) {
this.dateObject = [];
}
if (this.lastChanged !== obj) {
this.propagateChange(obj);
this.emitChange(withToolTip);
}
else {
if (isDateTypeChanged) {
this.emitChange(withToolTip);
}
}
this.lastChanged = obj;
if (this.controlDir.errors) {
if (this.controlDir.errors["date-maximum"]) {
this.errorMessage = "Maximum date is invalid.";
}
if (this.controlDir.errors["date-minimum"]) {
this.errorMessage = "Minimum date is invalid.";
}
if (this.controlDir.errors["date-between"]) {
if (this._param.dateType === DateType.BS) {
this.errorMessage = `Date must between
${this.dpService.GetDateBS(this.controlDir.control["minDate"], this._param.dateFormatBS)}
and
${this.dpService.GetDateBS(this.controlDir.control["maxDate"], this._param.dateFormatBS)}
`;
}
else {
this.errorMessage = `Date must between ${this.controlDir.errors["date-between"]["date-minimum"]} and ${this.controlDir.errors["date-between"]["date-maximum"]}`;
}
}
if (this.controlDir.errors["required"]) {
if (this.formControl.value === "") {
this.errorMessage = `Date is required`;
}
else {
this.errorMessage = `Date is Invalid`;
}
}
if (this.errorMessage) {
this.formControl.setErrors(this.controlDir.errors);
}
}
else {
this.formControl.setErrors(null);
}
}
ngOnInit() {
}
ngOnDestroy() {
this.stateChanges.complete();
}
clearText() {
this.formControl.setValue('');
this.dateObject = [];
this.execPropagateChange(null);
}
setValue(initial, withToolTip) {
// if(this.readonly){return}
if (this.dateObject.length > 0) {
const startDate = this._param.dateType === DateType.AD ? `${this.dateObject[0].dateAD}` : `${this.dateObject[0].dateBS}`;
let endDate = '';
this.dateObject[0].selectedDateType = this._param.dateType;
if (!this.isRange) {
this.formControl.setValue(startDate);
}
else {
if (this.dateObject.length > 1) {
endDate = this._param.dateType === DateType.AD ? `${this.dateObject[1].dateAD}` : `${this.dateObject[1].dateBS}`;
this.dateObject[1].selectedDateType = this._param.dateType;
}
this.formControl.setValue(`${startDate} | ${endDate}`);
}
}
else {
this.formControl.setValue("");
}
if (this.dateObject && this.dateObject.length >= 1) {
if (this.isRange) {
this.execPropagateChange({
start: this.dateObject[0].date,
end: this.dateObject[1].date
}, true, withToolTip);
}
else {
this.execPropagateChange(this.dateObject[0].date, true, withToolTip);
}
}
else {
if (initial) {
this.formControl.setValue("");
}
this.execPropagateChange(null);
}
}
changeDateType() {
if (this._param.dateType === DateType.AD) {
this._param.dateType = DateType.BS;
}
else {
this._param.dateType = DateType.AD;
}
this.changeDateFormat(this._param.dateType, this._param.dateType === DateType.AD ? this._param.dateFormatAD : this._param.dateFormatBS);
this.setValue(false, false);
}
showPicker() {
if (this.isPickerVisible) {
return;
}
this.isPickerVisible = true;
const currentDate = this.dateObject.length > 0 ? this.dateObject[0].date : new Date();
if (this.withTime) {
this.closeOnClick = false;
}
this.calPopUp.dateRange = this.isRange;
this.calPopUp.showCalendar(this._param.dateType, this._param.dateFormatAD, this._param.dateFormatBS, this.withTime, this.controlDir.control["minDate"], this.controlDir.control["maxDate"], this.closeOnClick, currentDate, this.language);
this.menuTrigger.openMenu();
}
setTooltip() {
let result = '';
if (this.dateObject && this.dateObject.length > 0) {
if (this.isRange) {
const ad = `AD: ${this.dpService.getFormatedDateLong(this.dateObject[0].dateAD, this._param.dateFormatAD, DateType.AD)} to ${this.dpService.getFormatedDateLong(this.dateObject[1].dateAD, this._param.dateFormatAD, DateType.AD)} \n`;
const bs = `BS: ${this.dpService.getFormatedDateLong(this.dateObject[0].dateBS, this._param.dateFormatBS, DateType.BS)} to ${this.dpService.getFormatedDateLong(this.dateObject[1].dateBS, this._param.dateFormatBS, DateType.BS)} \n`;
if (this._param.dateType === DateType.AD) {
result = `${ad} ${bs}`;
}
else {
result = `${bs} ${ad}`;
}
}
else {
const ad = `AD: ${this.dpService.getFormatedDateLong(this.dateObject[0].dateAD, this._param.dateFormatAD, DateType.AD)} \n`;
const bs = `BS: ${this.dpService.getFormatedDateLong(this.dateObject[0].dateBS, this._param.dateFormatBS, DateType.BS)} \n`;
const longDateString = (new Date(this.dateObject[0].date)).toString().replace("00:00:00", ""); // this.dateObject[0].date.toString().replace("00:00:00","");
if (this._param.dateType === DateType.AD) {
result = `${ad} ${bs} \n Date: ${longDateString}`;
}
else {
result = `${bs} ${ad} \n Date: ${longDateString}`;
}
}
}
else {
result = `Display Type: ${this._param.dateType === DateType.AD ? this.caption.AD[this.language] + ', ' : this.caption.BS[this.language]}`;
result = `${result} \n Format: ${this.dateFormat}`;
}
this.tooltipText = result;
}
dateChangedFromPopUp(result) {
this.menuTrigger.closeMenu();
this.isPickerVisible = false;
if (this.disabled || this.readonly) {
this.snackbar.open("Date Is Readonly!", "Cancel", { duration: 3000 });
return;
}
if (result === undefined) {
return;
}
else if (result !== -1) {
if (result.length >= 1) {
// console.log(this._param.dateType, result[0].selectedDateType)
if (this._param.dateType !== result[0].selectedDateType) {
this._param.dateType = result[0].selectedDateType;
this.changeDateFormat(this._param.dateType);
}
let index = 0;
if (!this.isRange) {
if (this._param.dateType === DateType.AD) {
this.formControl.setValue(result[0].dateAD);
}
else {
this.formControl.setValue(result[0].dateBS);
}
}
else {
if (this._param.dateType === DateType.AD) {
this.formControl.setValue(`${result[0].dateAD} | ${result[1].dateAD}`);
}
else {
this.formControl.setValue(`${result[0].dateBS} | ${result[1].dateBS}`);
}
}
result.forEach((el) => {
this.setDateObject(index, el.date, el.dateBS, el.dateAD, el.selectedDateType);
index++;
});
if (this.isRange) {
this.execPropagateChange({
start: this.dateObject[0].date,
end: this.dateObject[1].date
});
}
else {
this.execPropagateChange(this.dateObject[0].date);
}
this.dateInput.nativeElement.focus();
}
}
}
onMenuClosed() {
this.isPickerVisible = false;
this.dateInput.nativeElement.focus();
}
}
DateComponent.decorators = [
{ type: Component, args: [{
selector: 'ngx-date',
template: "<mat-form-field class=\"full-width\" style=\"max-width: fit-content;\">\r\n <input matInput #dateInput [textMask]=\"{mask: datemask}\" [formControl]=\"formControl\" [placeholder]=\"placeholder\"\r\n [matTooltip]=\"tooltipText\" matTooltipPosition=\"above\" matTooltipClass=\"date-tooltip\" #tooltip=\"matTooltip\"\r\n (change)=\"onManualChange($event)\" (paste)=\"onManualChange($event)\" (keyup)=\"onManualChange($event)\"\r\n (keydown)=\"onManualChange($event)\" (blur)=\"onBlur($event)\"\r\n (focus)=\"(!isPickerVisible && readonly)? tooltip.hide():tooltip.show()\" [errorStateMatcher]=\"matcher\"\r\n [required]=\"required\" autocomplete=\"off\" [readonly]=\"readonly\">\r\n\r\n <button *ngIf=\"!readonly && formControl.value\" mat-button type=\"button\" [matTooltip]=\"clearTooltip\" tabindex=\"-1\"\r\n matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearText()\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n <div *ngIf=\"readonly || !formControl.value\" class=\"icon-placement\" matSuffix>\r\n\r\n </div>\r\n\r\n <button mat-button [matTooltip]=\"changeDateTooltip\" type=\"button\" matTooltipPosition=\"above\" matSuffix\r\n mat-icon-button aria-label=\"Calendar\" tabindex=\"-1\" (click)=\"changeDateType()\">\r\n <mat-icon>repeat</mat-icon>\r\n </button>\r\n <button mat-button [matTooltip]=\"showCalendarTooltip\" tabindex=\"-1\" type=\"button\" matSuffix mat-icon-button\r\n aria-label=\"Calendar\" (click)=\"$event.stopPropagation();$event.preventDefault(); showPicker()\">\r\n <mat-icon>date_range</mat-icon>\r\n </button>\r\n\r\n <div [matMenuTriggerFor]=\"calendarPopUp\" #menu style=\"background-color: transparent; width: 0px; \"></div>\r\n\r\n <mat-hint>\r\n {{param.dateType===1? caption.AD[language]+', ': caption.BS[language] +', '}}\r\n Format: {{dateFormat}} {{withTime==true? 'hh:mm':''}}\r\n </mat-hint>\r\n <mat-error>\r\n {{errorMessage}} </mat-error>\r\n</mat-form-field>\r\n\r\n\r\n<mat-menu #calendarPopUp=\"matMenu\" class=\"popup\" x-position=\"before\" yPosition=\"below\" [overlapTrigger]=\"false\"\r\n (close)=\"onMenuClosed()\">\r\n <div (click)=\"$event.stopPropagation()\">\r\n <app-calendar-popup #calPopUp [dateRange]=\"false\" (DateTimeChanged)=\"dateChangedFromPopUp($event)\">\r\n </app-calendar-popup>\r\n </div>\r\n</mat-menu>\r\n\r\n<!-- <div class=\"date-tooltip\" style=\"width: 500px; height: 100px;\"></div> -->",
encapsulation: ViewEncapsulation.None,
styles: [".date-tooltip{background:#f0eec9;border-bottom:3px solid #a9a6a6;border-left:2px solid #726c6c;color:navy!important;font-size:14px;line-height:20px;max-width:250px!important;min-width:150px!important;text-align:center;white-space:pre-line}.mat-menu-content:not(:empty){padding-bottom:0!important;padding-top:0!important}.full-width{width:100%}.icon-placement{border-right:21px solid transparent;display:inline}"]
},] }
];
DateComponent.ctorParameters = () => [
{ type: CalendarService },
{ type: MatSnackBar },
{ type: NgControl, decorators: [{ type: Self }, { type: Optional }] }
];
DateComponent.propDecorators = {
calPopUp: [{ type: ViewChild, args: ['calPopUp', { static: false },] }],
menuTrigger: [{ type: ViewChild, args: [MatMenuTrigger, { static: false },] }],
dateInput: [{ type: ViewChild, args: ["dateInput", { static: true },] }],
elTooltip: [{ type: ViewChild, args: ["tooltip",] }],
onDateChanged: [{ type: Output }],
param: [{ type: Input }],
required: [{ type: Input }],
withTime: [{ type: Input }],
placeholder: [{ type: Input }],
readonly: [{ type: Input }],
closeOnClick: [{ type: Input }],
disabled: [{ type: Input }],
isRange: [{ type: Input }],
language: [{ type: Input }]
};
class CalendarComponent {
constructor(dpService) {
this.dpService = dpService;
this.DateTimeChanged = new EventEmitter();
this.day = 1;
this.currentView = CalendarViewType.Both;
this.errorInBS = false;
this.lang = 0;
this.dateTypeTitle = '';
this.withTime = false;
this.todayColor = 'cornflowerblue';
this.selectedColor = 'rgb(239, 175, 175)';
this.backgroundColor = '#efebeb';
this.dayNameBackgroundColor = 'indianred';
this.hourMax = 23;
this.hourMin = 0;
this.showTicks = true;
this.hourStep = 1;
this.thumbLabel = true;
this.hourValue = 0;
this.minuteMax = 59;
this.minuteMin = 0;
this.minuteStep = 1;
this.minuteValue = 0;
this.cols = 7;
this.rowHeight = '35px';
this.defaultSelectedDate = null;
this.dateType = DateType.AD;
this.dateFormatAD = DateFormat.ddMMyyyy;
this.dateFormatBS = DateFormat.yyyyMMdd;
this.minDate = new Date(1913, 3, 13);
this.maxDate = new Date(new Date().getFullYear() + 100, new Date().getMonth(), new Date().getDate());
this.closeOnClick = true;
this.defaultDateRange = true;
this.currentDate = new Date();
}
set content(content) {
this.yearMonth = content;
}
get dateRange() {
return this.defaultDateRange;
}
set dateRange(val) {
this.defaultDateRange = val;
}
showCalendar(dateType, dateFormatAD, dateFormatBS, withTime, minDate, maxDate, closeOnClick, currentDate, lang) {
this.dateType = dateType;
this.dateFormatAD = dateFormatAD;
this.dateFormatBS = dateFormatBS;
this.withTime = withTime;
this.minDate = minDate;
this.maxDate = maxDate;
this.closeOnClick = closeOnClick;
this.currentDate = currentDate ? currentDate : new Date();
this.lang = lang;
if (this.lang === 0) {
if (this.dateType === 1) {
this.dateTypeTitle = 'AD';
}
else {
this.dateTypeTitle = 'BS';
}
}
else {
if (this.dateType === 1) {
this.dateTypeTitle = 'मिति';
}
else {
this.dateTypeTitle = 'गते';
}
}
this.setInitialCalendar(this.currentDate);
setTimeout(() => {
this.yearMonth.focus();
}, 100);
}
setInitialCalendar(val) {
if (this.dateType === DateType.AD) {
const currentDate = new Date(val);
this.year = currentDate.getFullYear();
this.month = currentDate.getMonth() + 1;
this.day = currentDate.getDate();
this.title = this.dpService.GetADMonthName(+this.month) + ', ' + this.year.toString();
this.setCalendarDay(+this.year, +this.month, +this.day, this.dateType, this.maxDate, this.minDate);
}
else {
const bsDate = this.dpService.GetDateBS(val, this.dateFormatBS);
this.year = this.dpService.GetBSYear(bsDate, this.dateFormatBS);
this.month = this.dpService.GetBSMonth(bsDate, this.dateFormatBS);
this.day = this.dpService.GetBSDay(bsDate, this.dateFormatBS);
this.title = this.dpService.GetBSMonthName(+this.month) + ', ' + this.year;
this.setCalendarDay(+this.year, +this.month, +this.day, this.dateType, this.maxDate, this.minDate);
}
if (!!this.withTime) {
this.hourValue = val.getHours();
this.minuteValue = val.getMinutes();
}
}
dateTypeToggle() {
if (this.dateType === DateType.AD) {
this.dateType = DateType.BS;
}
else {
this.dateType = DateType.AD;
}
if (this.lang === 0) {
if (this.dateType === 1) {
this.dateTypeTitle = 'AD';
}
else {
this.dateTypeTitle = 'BS';
}
}
else {
if (this.dateType === 1) {
this.dateTypeTitle = 'मिति';
}
else {
this.dateTypeTitle = 'गते';
}
}
this.setCalender();
}
get selectedDate() {
if (this.defaultSelectedDate === null) {
this.setDate();
}
return this.defaultSelectedDate;
}
setCalender() {
if (this.dateType === DateType.AD) {
const currentDate = new Date(this.currentDate);
this.year = currentDate.getFullYear();
this.month = currentDate.getMonth() + 1;
this.day = currentDate.getDate();
this.setCalendarDay(this.year, this.month, this.day, DateType.AD, this.maxDate, this.minDate);
}
else {
const bsDate = this.dpService.GetDateBS(this.currentDate, this.dateFormatBS);
this.year = this.dpService.GetBSYear(bsDate, this.dateFormatBS);
this.month = this.dpService.GetBSMonth(bsDate, this.dateFormatBS);
this.day = this.dpService.GetBSDay(bsDate, this.dateFormatBS);
this.setCalendarDay(this.year, this.month, this.day, DateType.BS, this.maxDate, this.minDate);
}
this.setDate();
this.settime();
}
setCalendarDay(year, month, day, dType, maxDate, minDate) {
const today = new Date(new Date().toDateString());
const dayList = this.dpService.GetWeekDayPrefixList();
this.cols = 7;
this.rowHeight = '35px';
this.currentView = CalendarViewType.Both;
this.datas = [];
this.titles = [];
this.month = month;
this.year = year;
// tslint:disable-next-line:prefer-for-of
for (let n = 0; n < dayList.length; n++) {
if (this.lang === 0) {
this.titles.push({ text: dayList[n].day, rows: 1, cols: 1, color: this.dayNameBackgroundColor });
}
else {
this.titles.push({ text: dayList[n].nepaliDay, rows: 1, cols: 1, color: this.dayNameBackgroundColor });
}
}
if (dType === DateType.AD) {
// this.dateType = 'AD';
this.title = this.dpService.GetADMonthName(month) + ', ' + year;
const d = new Date(year, month - 1, 1).getDay();
const dInm = new Date(year, month, 0).getDate();
if (d > 0) {
// tslint:disable-next-line:no-shadowed-variable
for (let i = 0; i < d; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
let curDate;
let disable = 'false';
const currentDate = new Date(this.currentDate);
const selDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
for (let i = 1; i <= dInm; i++) {
curDate = new Date(year, month - 1, i);
if (curDate < minDate || curDate > maxDate) {
disable = 'true';
}
else {
disable = 'false';
}
if (curDate.getTime() === today.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.todayColor, disable });
}
else if (curDate.getTime() === selDate.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.selectedColor, disable });
}
else {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.backgroundColor, disable });
}
}
for (let i = this.datas.length; i <= 41; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
else {
let d = new Date(year, month - 1, 1).getDay();
// this.dateType = 'BS';
this.title = this.dpService.GetBSMonthName(month) + ', ' + year;
try {
d = this.dpService.GetDateAD(+year, +month, 1).getDay();
}
catch (e) {
this.errorInBS = true;
return;
}
const dInm = this.dpService.GetDaysInMonthBS(+year, +month);
let disable = 'false';
// var selDate: Date = this.dpService.GetDateAD(+year, +month, +day)
const currentDate = new Date(this.currentDate);
const selDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
if (d > 0) {
for (let i = 0; i < d; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
for (let i = 1; i <= dInm; i++) {
const curDate = this.dpService.GetDateAD(+year, +month, i);
if (curDate < minDate || curDate > maxDate) {
disable = 'true';
}
else {
disable = 'false';
}
if (curDate.getTime() === today.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.todayColor, disable });
}
else if (curDate.getTime() === selDate.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.selectedColor, disable });
}
else {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.backgroundColor, disable });
}
}
for (let i = this.datas.length; i <= 41; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
this.setDisplayDate();
}
setDisplayDate() {
const ad = new Date(this.selectedDate.date.getFullYear(), this.selectedDate.date.getMonth(), this.selectedDate.date.getDate());
let yr = this.selectedDate.date.getFullYear();
let mn = this.selectedDate.date.getMonth() + 1;
let dy = this.selectedDate.date.getDate();
let mnName = '';
if (this.dateType === DateType.AD) {
const bsDate = this.dpService.GetDateBS(ad, this.dateFormatBS);
if (bsDate === null) {
this.errorInBS = true;
this.displayDate = 'BS Calendar Not Found!';
return;
}
yr = this.dpService.GetBSYear(bsDate, this.dateFormatBS);
mn = this.dpService.GetBSMonth(bsDate, this.dateFormatBS);
dy = this.dpService.GetBSDay(bsDate, this.dateFormatBS);
mnName = this.dpService.GetBSMonthName(mn);
}
else {
mnName = this.dpService.GetADMonthName(mn);
}
this.displayDate = (this.dateType === DateType.AD) ? 'BS: ' : 'AD: ';
this.displayDate = this.displayDate + dy + ' ' + mnName + ' ' + yr;
}
setCalendarMonth(year, dType) {
let disable = 'false';
this.cols = 3;
this.rowHeight = this.withTime ? '70px' : '60px';
;
this.datas = [];
this.currentView = CalendarViewType.Month;
let minYearMnth = this.minDate ? this.minDate.getFullYear().toString() : undefined;
let maxYearMnth = this.maxDate ? this.maxDate.getFullYear().toString() : undefined;
if (minYearMnth) {
minYearMnth = minYearMnth + (this.minDate.getMonth() < 10 ? '0' +
this.minDate.getMonth().toString() : this.minDate.getMonth().toString());
}
if (maxYearMnth) {
maxYearMnth = maxYearMnth + (this.maxDate.getMonth() < 10 ? '0' +
this.maxDate.getMonth().toString() : this.maxDate.getMonth().toString());
}
if (this.dateType === DateType.BS) {
let bs = this.dpService.GetDateBS(this.minDate, this.dateFormatBS);
if (bs === null) {
minYearMnth = this.dpService.GetMinYear().toString() + '00';
}
else {
minYearMnth = this.dpService.GetBSYear(bs, this.dateFormatBS).toString();
const mnth = (this.dpService.GetBSMonth(bs, this.dateFormatBS) - 1).toString();
minYearMnth = minYearMnth + (+mnth < 10 ? '0' + mnth.toString() : mnth.toString());
}
bs = this.dpService.GetDateBS(this.maxDate, this.dateFormatBS);
if (bs === null) {
maxYearMnth = this.dpService.GetMaxYear().toString() + '11';
}
else {
maxYearMnth = this.dpService.GetBSYear(bs, this.dateFormatBS).toString();
const mnth = (this.dpService.GetBSMonth(bs, this.dateFormatBS) - 1).toString();
maxYearMnth = maxYearMnth + (+mnth < 10 ? '0' + mnth.toString() : mnth.toString());
}
}
let monthList;
if (dType === DateType.AD) {
monthList = this.dpService.GetADMonthList();
}
else {
monthList = this.dpService.GetBSMonthList();
}
let curYearMnth = '';
for (let i = 0; i < monthList.length; i++) {
curYearMnth = year.toString() + (i < 10 ? '0' + i.toString() : i.toString());
if (curYearMnth < minYearMnth || curYearMnth > maxYearMnth) {
disable = 'true';
}
else {
disable = 'false';
}
this.datas.push({ text: monthList[i].month, id: i + 1, rows: 1, cols: 1, color: this.backgroundColor, disable });
}
this.settime();
}
setCalendarYear(fromYear, toYear) {
let disable = 'false';
this.cols = 3;
this.rowHeight = this.withTime ? '70px' : '60px';
this.datas = [];
this.currentView = CalendarViewType.Year;
let minYearMnth = this.minDate ? this.minDate.getFullYear() : undefined;
let maxYearMnth = this.maxDate ? this.maxDate.getFullYear() : undefined;
if (this.dateType === DateType.BS) {
let bs = this.dpService.GetDateBS(this.minDate, this.dateFormatBS);
if (bs === null) {
minYearMnth = this.dpService.GetMinYear();
}
else {
minYearMnth = this.dpService.GetBSYear(bs, this.dateFormatBS);
}
bs = this.dpService.GetDateBS(this.maxDate, this.dateFormatBS);
if (bs === null) {
maxYearMnth = this.dpService.GetMaxYear();
}
else {
maxYearMnth = this.dpService.GetBSYear(bs, this.dateFormatBS);
}
}
for (let i = fromYear - 1; i <= toYear + 1; i++) {
if (i < minYearMnth || i > maxYearMnth) {
disable = 'true';
}
else {
disable = 'false';
}
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.backgroundColor, disable });
}
this.settime();
}
settime() {
if (this.withTime) {
if (this.currentDate) {
this.hourValue = this.currentDate.getHours();
this.minuteValue = this.currentDate.getMinutes();
}
else {
this.hourValue = 0;
this.minuteValue = 0;
}
}
}
titleClick() {
if (this.currentView === CalendarViewType.Both) {
this.currentView = CalendarViewType.Month;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === CalendarViewType.Month) {
this.currentView = CalendarViewType.Year;
let datePart = this.year.toString().substring(0, 3) + '0';
this.fromYear = +datePart;
datePart = this.year.toString().substring(0, 3) + '9';
this.toYear = +datePart;
this.title = this.fromYear.toString() + '-' + this.toYear.toString();
this.setCalendarYear(this.fromYear, this.toYear);
}
}
upDown(ev) {
if (ev === '+') {
if (this.currentView === CalendarViewType.Month) {
this.year = this.year - 1;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === CalendarViewType.Year) {
this.fromYear = this.fromYear - 10;
this.toYear = this.toYear - 10;
this.title = this.fromYear.toString() + '-' + this.toYear.toString();
this.setCalendarYear(this.fromYear, this.toYear);
}
else if (this.currentView === CalendarViewType.Both) {
if (this.month === 1) {
this.month = 12;
this.year = this.year - 1;
}
else {
this.month = this.month - 1;
}
if (this.dateType === DateType.BS) {
this.monthName = this.dpService.GetBSMonthName(this.month);
}
else {
this.monthName = this.dpService.GetADMonthName(this.month);
}
this.title = this.monthName + ', ' + this.year;
this.setCalendarDay(this.year, this.month, this.day, this.dateType, this.maxDate, this.minDate);
}
}
else {
if (this.currentView === CalendarViewType.Month) {
this.year = this.year + 1;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === CalendarViewType.Year) {
this.fromYear = this.fromYear + 10;
this.toYear = this.toYear + 10;
this.title = this.fromYear.toString() + '-' + this.toYear.toString();
this.setCalendarYear(this.fromYear, this.toYear);
}
else if (this.currentView === CalendarViewType.Both) {
if (this.month === 12) {
this.month = 1;
this.year = this.year + 1;
}
else {
this.month = this.month + 1;
}
// this.month = this.month + 1;
if (this.dateType === DateType.BS) {
this.monthName = this.dpService.GetBSMonthName(this.month);
}
else {
this.monthName = this.dpService.GetADMonthName(this.month);
}
this.title = this.monthName + ', ' + this.year;
this.setCalendarDay(this.year, this.month, this.day, this.dateType, this.maxDate, this.minDate);
}
}
}
ItemClicked(ev) {
if (this.currentView === CalendarViewType.Both) {
this.day = +ev;
const today = new Date(new Date().toDateString());
let curDate = new Date(this.year, this.month, 1);
const index = this.datas.findIndex(img => img.id === ev);
if (this.dateType === DateType.AD) {
for (let i = 0; i < this.datas.length; i++) {
curDate = new Date(this.year, this.month - 1, +this.datas[i].text);
if (today.getTime() === curDate.getTime()) {
this.datas[i].color = this.todayColor;
}
else {
if (i !== index) {
this.datas[i].color = this.backgroundColor;
}
else {
this.datas[i].color = this.selectedColor;
}
}
}
}
else {
for (let i = 0; i < this.datas.length; i++) {
curDate = this.dpService.GetDateAD(this.year, this.month, +this.datas[i].text);
if (today.getTime() === curDate.getTime()) {
this.datas[i].color = this.todayColor;
}
else {
if (i !== index) {
this.datas[i].color = this.backgroundColor;
}
else {
this.datas[i].color = this.selectedColor;
}
}
}
}
this.returnDate();
}
else if (this.currentView === CalendarViewType.Year) {
this.currentView = CalendarViewType.Month;
this.year = ev;
if (this.dateType === DateType.AD) {
this.monthName = this.dpService.GetADMonthName(this.month);
}
else {
this.monthName = this.dpService.GetBSMonthName(this.month);
}
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === CalendarViewType.Month) {
this.month = ev;
if (this.dateType === DateType.AD) {
this.monthName = this.dpService.GetADMonthName(this.month);
}
else {
this.monthName = this.dpService.GetBSMonthName(this.month);
}
this.title = this.monthName + ', ' + this.year;
this.currentView = CalendarViewType.Both;
this.setCalendarDay(this.year, this.month, 1, this.dateType, this.maxDate, this.minDate);
}
}
setDate() {
let dt;
if (this.dateType === DateType.AD) {
dt = new Date(+this.year, +this.month - 1, +this.day);
}
else {
dt = this.dpService.GetDateAD(+this.year, +this.month, +this.day);
}
let dtAD = this.dpService.GetFormatedDateAD(dt, this.dateFormatAD);
let dtBS = null;
try {
dtBS = this.dpService.GetDateBS(dt, this.dateFormatBS);
}
catch (e) {
dtBS = '';
}
if (!!this.withTime) {
const hr = (+this.hourValue < 10) ? '0' + this.hourValue.toString() : this.hourValue.toString();
const min = (+this.minuteValue < 10) ? '0' + this.minuteValue.toString() : this.minuteValue.toString();
dt = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate(), +this.hourValue, +this.minuteValue);
dtAD = dtAD + ' ' + hr.toString() + ':' + min.toString();
if (dtBS) {
dtBS = dtBS + ' ' + hr.toString() + ':' + min.toString();
}
else {
dtBS = '';
}
// this.hourValue = this.hourValue;
// this.minDate = this.minuteValue;
}
this.defaultSelectedDate = {
dateAD: dtAD,
dateBS: dtBS,
date: dt,
selectedDateType: this.dateType
};
this.currentDate = dt;
}
returnDate() {
this.setDate();
this.setDisplayDate();
// if (this.closeOnClick) {
// if (!this.dateRange) {
// if (!this.withTime) {
this.DateTimeChanged.emit(this.defaultSelectedDate);
// }
// }
// }
}
onInputChange(ev, flag) {
if (flag === 'm') {
this.minuteValue = ev.value;
}
else {
this.hourValue = ev.value;
}
this.returnDate();
}
}
CalendarComponent.decorators = [
{ type: Component, args: [{
// tslint:disable-next-line:component-selector
selector: 'dp-calendar',
template: "<div class=\"fx-column\">\r\n <div class=\"dp-title\">\r\n <div>\r\n <button #yearmonth mat-button color=\"primary\" (click)=\"titleClick()\">\r\n {{title}}\r\n </button>\r\n </div>\r\n <button mat-button mat-icon-button class=\"button-size\" color=\"primary\" (click)=\"dateTypeToggle()\"\r\n [disabled]=\"errorInBS\">\r\n {{dateTypeTitle}}\r\n </button>\r\n\r\n <div class=\"year-month\">\r\n <button mat-button mat-icon-button color=\"primary\" (click)=\"upDown('+')\" class=\"button-size\">\r\n <mat-icon class=\"mat-14\">arrow_drop_up</mat-icon>\r\n </button>\r\n <button mat-button mat-icon-button color=\"primary\" (click)=\"upDown('-')\" class=\"button-size\">\r\n <mat-icon>arrow_drop_down</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <!-- Calendar Body -->\r\n <div class=\"fx-column\">\r\n <div style=\"padding-bottom:1px\">\r\n <mat-grid-list *ngIf=\"currentView==1\" [cols]=\"cols\" rowHeight=\"25px\">\r\n <mat-grid-tile *ngFor=\"let data of titles\" [colspan]=\"data.cols\" [rowspan]=\"data.rows\"\r\n [style.background]=\"data.color\" style=\"color:white;\">\r\n <span class=\"text-label\">{{data.text}}</span>\r\n </mat-grid-tile>\r\n </mat-grid-list>\r\n </div>\r\n <mat-grid-list *ngIf=\"currentView==1\" [cols]=\"cols\" [rowHeight]=\"rowHeight\">\r\n <mat-grid-tile *ngFor=\"let data of datas\" [colspan]=\"data.cols\" [rowspan]=\"data.rows\" [style.background]=\"data.color\">\r\n <button *ngIf=\"data.id!=0\" mat-fab-button mat-icon-button mat-raised-button [disabled]=\"data.disable\"\r\n color=\"\" [style.width]=\"'25px'\" [style.height]=\"'25px'\"\r\n [style.line-height]=\"'25px'\" (click)=\"ItemClicked(data.id)\">\r\n {{data.text}}\r\n </button>\r\n </mat-grid-tile>\r\n </mat-grid-list>\r\n <mat-grid-list *ngIf=\"currentView!=1\" [cols]=\"cols\" [rowHeight]=\"rowHeight\">\r\n <mat-grid-tile *ngFor=\"let data of datas\" [colspan]=\"data.cols\" [rowspan]=\"data.rows\" [style.background]=\"data.color\">\r\n <button *ngIf=\"data.id!=0\" mat-button [disabled]=\"data.disable\" color=\"\" (click)=\"ItemClicked(data.id)\">\r\n {{data.text}}\r\n </button>\r\n </mat-grid-tile>\r\n </mat-grid-list>\r\n </div>\r\n <!-- Time body -->\r\n <div class=\"fx-row\" *ngIf=\"withTime && currentView==1\" >\r\n <div class=\"fx-column-time\">\r\n <mat-slider thumbLabel [max]=\"hourMax\" [min]=\"hourMin\" [step]=\"hourStep\" color=\"primary\"\r\n tick-interval=\"1\" [(ngModel)]=\"hourValue\" [value]=\"hourValue\" (input)=\"onInputChange($event,'h')\">\r\n </mat-slider>\r\n <div class=\"fx-row-m15\">\r\n <span class=\"text-label\">Hour:</span>\r\n <span class=\"text-label\">{{hourValue}}</span>\r\n </div>\r\n </div>\r\n <div class=\"fx-column-time\">\r\n <mat-slider thumbLabel [max]=\"minuteMax\" [min]=\"minuteMin\" [step]=\"minuteStep\" \r\n tick-interval=\"1\" color=\"primary\" [(ngModel)]=\"minuteValue\" [value]=\"minuteValue\" (input)=\"onInputChange($event,'m')\">\r\n </mat-slider>\r\n <div class=\"fx-row-m15\">\r\n <span class=\"text-label\">Minute:</span>\r\n <span class=\"text-label\">{{minuteValue}}</span>\r\n </div>\r\n </div>\r\n </div>\r\n</div>",
styles: [".dp-title,:host{display:flex}.dp-title{align-items:center;box-sizing:border-box;flex-direction:row;min-width:275px;place-content:center space-between}.button-size{height:30px;line-height:30px;width:30px}.fx-column,.fx-column-time{box-sizing:border-box;display:flex;flex-direction:column}.fx-column-time{align-items:center}.fx-row{background-color:#ebefec;margin-top:1px;padding-left:10px}.fx-row,.fx-row-m15{box-sizing:border-box;display:flex;flex-direction:row}.fx-row-m15{margin-top:-15px}.text-bold,.text-label{font-family:Roboto,Helvetica Neue,sans-serif;font-size:14px}.text-bold{font-weight:700}.mat-menu-content{padding:0!important}"]
},] }
];
CalendarComponent.ctorParameters = () => [
{ type: CalendarService }
];
CalendarComponent.propDecorators = {
content: [{ type: ViewChild, args: ['yearmonth', { static: false },] }],
DateTimeChanged: [{ type: Output }],
dateRange: [{ type: Input }]
};
class CalendarPopupComponent {
constructor() {
this.DateTimeChanged = new EventEmitter();
this.fromToTitle = 'From Date';
this.isFront = true;
this.className = '';
this.withTime = false;
this.dateType = DateType.AD;
this.dateFormatAD = DateFormat.ddMMyyyy;
this.dateFormatBS = DateFormat.yyyyMMdd;
this.minDate = new Date(1913, 3, 13);
this.maxDate = new Date(new Date().getFullYear() + 100, new Date().getMonth(), new Date().getDate());
this.closeOnClick = true;
this.defaultDateRange = true;
this.lang = 0;
this.currentDate = new Date();
}
get dateRange() {
return this.defaultDateRange;
}
set dateRange(val) {
this.defaultDateRange = val;
}
showCalendar(dateType, dateFormatAD, dateFormatBS, withTime, minDate, maxDate, closeOnClick, currentDate, lang) {
this.isFront = true;
this.dateType = dateType;
this.dateFormatAD = dateFormatAD;
this.dateFormatBS = dateFormatBS;
this.withTime = withTime;
this.minDate = minDate;
this.maxDate = maxDate;
this.closeOnClick = closeOnClick;
this.currentDate = currentDate ? currentDate : new Date();
this.lang = lang;
if (this.lang === 0) {
this.fromToTitle = 'From Date';
}
else {
this.fromToTitle = 'देखि';
}
this.selectedToDate = null;
this.cal1.showCalendar(this.dateType, this.dateFormatAD, this.dateFormatBS, this.withTime, this.minDate, this.maxDate, this.closeOnClick, this.currentDate, this.lang);
if (this.withTime) {
if (this.dateRange) {
this.className = 'container with-range-with-time';
}
else {
this.className = 'container without-range-with-time';
}
}
else {
if (this.dateRange) {
this.className = 'container with-range';
}
else {
this.className = 'container without-range';
}
}
}
ngOnInit() {
}
revert() {
this.DateTimeChanged.emit(undefined);
}
submit() {
let result;
if (this.dateRange === false) {
result = [this.cal1.selectedDate];
this.DateTimeChanged.emit(result);
}
else {
if (this.isFront === true) {
this.nextPanel();
}
else {
result = [this.cal1.selectedDate, this.cal2.selectedDate];
this.DateTimeChanged.emit(result);
}
}
}
datetimeChangedFrom(e) {
this.selectedFromDate = {
date: e.date,
dateAD: e.dateAD,
dateBS: e.dateBS,
selectedDateType: e.selectedDateType
};
if (this.dateRange === false) {
if (this.closeOnClick === true) {
const result = [
this.selectedFromDate
];
this.DateTimeChanged.emit(result);
return;
}
}
else {
if (this.closeOnClick === true) {
this.nextPanel();
}
}
}
datetimeChangedTo(e) {
this.selectedToDate = {
date: e.date,
dateAD: e.dateAD,
dateBS: e.dateBS,
selectedDateType: e.selectedDateType
};
if (this.closeOnClick === true) {
const result = [this.selectedFromDate, this.selectedToDate];
this.DateTimeChanged.emit(result);
}
}
nextPanel() {
if (this.lang === 0) {
this.fromToTitle = 'To Date';
}
else {
this.fromToTitle = 'सम्म';
}
if (this.selectedFromDate == null) {
this.selectedFromDate = this.cal1.selectedDate;
}
const minDate = new Date(this.selectedFromDate.date.toDateString());
this.cal2.showCalendar(this.selectedFromDate.selectedDateType, this.dateFormatAD, this.dateFormatBS, this.withTime, minDate, this.maxDate, this.closeOnClick, minDate, this.lang);
this.isFront = !this.isFront;
}
previousPanel() {
if (this.lang === 0) {
this.fromToTitle = 'From Date';
}
else {
this.fromToTitle = 'देखि';
}
this.selectedToDate = null;
this.isFront = !this.isFront;
}
}
CalendarPopupComponent.decorators = [
{ type: Component, args: [{
selector: 'app-calendar-popup',
template: "<section [class]=\"className\">\r\n <div *ngIf=\"dateRange==true\" class=\"range-heading\">\r\n <button *ngIf=\"isFront==false\" mat-button mat-icon-button color=\"primary\" tabindex=\"-1\"\r\n (click)=\"previousPanel()\">\r\n <mat-icon class=\"mat-14\">chevron_left</mat-icon>\r\n </button>\r\n <div style=\"padding-left:16px; padding-right:16px;\">\r\n <label class=\"text-bold\">{{fromToTitle}}</label>\r\n </div>\r\n <button *ngIf=\"isFront==true\" mat-button mat-icon-button color=\"primary\" tabindex=\"-1\"\r\n (click)=\"nextPanel()\">\r\n <mat-icon class=\"mat-14\">chevron_right</mat-icon>\r\n </button>\r\n </div>\r\n\r\n <div #card class=\"card\" [ngClass]=\"isFront===true? 'card' : 'card flipped'\">\r\n <div class=\"front\">\r\n <dp-calendar [ngClass]=\"isFront===true? 'active' : 'none-active'\" #cal1 [dateRange]=\"dateRange\"\r\n (DateTimeChanged)=\"datetimeChangedFrom($event)\">\r\n </dp-calendar>\r\n </div>\r\n <div class=\"back\">\r\n <dp-calendar [ngClass]=\"isFront===true? 'none-active' : 'active'\" #cal2 [dateRange]=\"dateRange\"\r\n (DateTimeChanged)=\"datetimeChangedTo($event)\">\r\n </dp-calendar>\r\n </div>\r\n\r\n </div>\r\n <div *ngIf=\"withTime===true\" class=\"footer-with-time\" style.padding=\"20px\">\r\n <div class=\"button-container\">\r\n <button mat-button (click)=\"revert()\">{{lang==0?'Cancel':'\u0930\u0926\u094D\u0926'}}</button>\r\n <button mat-button (click)=\"submit()\">{{lang==0?'Ok':'\u0920\u093F\u0915'}}</button>\r\n </div>\r\n </div>\r\n</section>",
styles: [".with-range{height:318px}.with-range-with-time{height:405px}.without-range{height:277px}.without-range-with-time{height:365px}.footer-with-time{background:#fff;display:flex;place-content:flex-end;position:relative;top:327px;width:100%}.button-container{align-self:flex-end}.button-container>*{min-width:100px}.container{border:1px solid #ccc;overflow:hidden;width:275px}.card,.container{position:relative}.card{-transform-origin:50% 50%;transform-style:preserve-3d;transition:transform .25s;width:100%}.card div{-webkit-backface-visibility:hidden;backface-visibility:hidden;display:block;height:100%;position:absolute;text-align:center;width:100%}.card .front{background:#ccc}.card .back{transform:rotateY(180deg)}.active{background-color:#fff}.none-active{background-color:silver;display:none}.card.flipped{transform:rotateY(180deg)}.range-heading{align-items:center;display:flex;justify-content:space-between}"]
},] }
];
CalendarPopupComponent.ctorParameters = () => [];
CalendarPopupComponent.propDecorators = {
DateTimeChanged: [{ type: Output }],
cal1: [{ type: ViewChild, args: ['cal1', { static: false },] }],
cal2: [{ type: ViewChild, args: ['cal2', { static: false },] }],
card: [{ type: ViewChild, args: ['card', { static: false },] }],
dateRange: [{ type: Input }]
};
class NgxMatCalendarModule {
}
NgxMatCalendarModule.decorators = [
{ type: NgModule, args: [{
declarations: [DateComponent, CalendarComponent, CalendarPopupComponent],
imports: [
CommonModule,
MatInputModule,
MatDialogModule,
MatToolbarModule,
MatIconModule,
MatCardModule,
MatSnackBarModule,
MatGridListModule,
MatFormFieldModule,
MatButtonModule,
MatSliderModule,
MatMenuModule,
MatTooltipModule,
FormsModule,
ReactiveFormsModule,
TextMaskModule,
],
exports: [DateComponent],
providers: [CalendarService]
},] }
];
const moment$1 = moment_;
// @dynamic
class DateValidators {
static dateMinimum(date) {
return (control) => {
control["minDate"] = date;
if (control.value == null) {
return null;
}
const FORMAT_DATE = 'YYYY-MM-DD';
const controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
const validationDate = moment$1(date, FORMAT_DATE);
return controlDate.isSameOrAfter(validationDate, 'day') ? null : {
'date-minimum': {
'date-minimum': validationDate.format(FORMAT_DATE),
'actual': controlDate.format(FORMAT_DATE)
}
};
};
}
static dateMaximum(date) {
return (control) => {
control["maxDate"] = date;
if (control.value == null) {
return null;
}
const FORMAT_DATE = 'YYYY-MM-DD';
const controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
const validationDate = moment$1(date, FORMAT_DATE);
return controlDate.isSameOrBefore(validationDate, "day") ? null : {
'date-maximum': {
'date-maximum': validationDate.format(FORMAT_DATE),
'actual': controlDate.format(FORMAT_DATE)
}
};
};
}
static dateBetween(startDate, endDate) {
return (control) => {
control["maxDate"] = endDate;
control["minDate"] = startDate;
const FORMAT_DATE = 'YYYY-MM-DD';
if (control.value == null) {
return null;
}
const validationStartDate = moment$1(startDate, FORMAT_DATE);
const validationEndDate = moment$1(endDate, FORMAT_DATE);
if (control.value.start) {
const controlStartDate = moment$1(control.value.start, FORMAT_DATE);
const controlEndDate = moment$1(control.value.end, FORMAT_DATE);
if (!controlStartDate.isValid()) {
return null;
}
if (!controlEndDate.isValid()) {
return null;
}
if (controlStartDate.isSame(controlEndDate, 'day')) {
const isSameOrAfter = controlStartDate.isSameOrAfter(validationStartDate, 'day');
const isSameOrBefore = controlStartDate.isSameOrBefore(validationEndDate, 'day');
if (!(isSameOrAfter && isSameOrBefore)) {
return {
'date-between': {
'date-minimum': validationStartDate.format(FORMAT_DATE),
'date-maximum': validationEndDate.format(FORMAT_DATE),
'actual ': `Start: ${controlStartDate.format(FORMAT_DATE)} End: ${controlEndDate.format(FORMAT_DATE)}`
}
};
}
}
else {
const sameMin = controlStartDate.isSameOrAfter(validationStartDate, 'day') && controlStartDate.isSameOrBefore(validationEndDate, 'day');
const sameMax = controlEndDate.isSameOrAfter(validationStartDate, 'day') && controlEndDate.isSameOrBefore(validationEndDate, 'day');
if (sameMax && sameMin) {
return null;
}
const isStartDateInRange = controlStartDate.isBetween(validationStartDate, validationEndDate);
const isEndDateInRange = controlEndDate.isBetween(validationStartDate, validationEndDate);
if (isStartDateInRange && isEndDateInRange) {
return null;
}
else {
return {
'date-between': {
'date-minimum': validationStartDate.format(FORMAT_DATE),
'date-maximum': validationEndDate.format(FORMAT_DATE),
'actual ': `Start: ${controlStartDate.format(FORMAT_DATE)} End: ${controlEndDate.format(FORMAT_DATE)}`
}
};
}
}
}
else {
const controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
const sameMin = controlDate.isSame(validationStartDate, 'day');
if (sameMin) {
return null;
}
const sameMax = controlDate.isSame(validationEndDate, 'day');
if (sameMax) {
return null;
}
return controlDate.isBetween(validationStartDate, validationEndDate) ? null : {
'date-between': {
'date-minimum': validationStartDate.format(FORMAT_DATE),
'date-maximum': validationEndDate.format(FORMAT_DATE),
'actual': controlDate.format(FORMAT_DATE)
}
};
}
};
}
}
/*
* Public API Surface of ngx-mat-calendar
*/
/**
* Generated bundle index. Do not edit.
*/
export { CalendarService, CalendarViewType, DateComponent, DateFormat, DateType, DateValidators, Day, EFrequencyIn, Language, Month, NgxMatCalendarModule, CalendarComponent as ɵa, CalendarPopupComponent as ɵb };
//# sourceMappingURL=ngx-mat-calendar.js.map