ngx-mat-calendar
Version:
A datepicker with nepali and english calendar support
2,850 lines • 162 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('@angular/material/menu'), require('moment'), require('rxjs'), require('@angular/cdk/coercion'), require('@angular/material/snack-bar'), require('@angular/common'), require('@angular/material/button'), require('@angular/material/card'), require('@angular/material/dialog'), require('@angular/material/form-field'), require('@angular/material/grid-list'), require('@angular/material/icon'), require('@angular/material/input'), require('@angular/material/slider'), require('@angular/material/toolbar'), require('@angular/material/tooltip'), require('angular2-text-mask')) :
typeof define === 'function' && define.amd ? define('ngx-mat-calendar', ['exports', '@angular/core', '@angular/forms', '@angular/material/menu', 'moment', 'rxjs', '@angular/cdk/coercion', '@angular/material/snack-bar', '@angular/common', '@angular/material/button', '@angular/material/card', '@angular/material/dialog', '@angular/material/form-field', '@angular/material/grid-list', '@angular/material/icon', '@angular/material/input', '@angular/material/slider', '@angular/material/toolbar', '@angular/material/tooltip', 'angular2-text-mask'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ngx-mat-calendar'] = {}, global.ng.core, global.ng.forms, global.ng.material.menu, global.moment_, global.rxjs, global.ng.cdk.coercion, global.ng.material.snackBar, global.ng.common, global.ng.material.button, global.ng.material.card, global.ng.material.dialog, global.ng.material.formField, global.ng.material.gridList, global.ng.material.icon, global.ng.material.input, global.ng.material.slider, global.ng.material.toolbar, global.ng.material.tooltip, global.angular2TextMask));
}(this, (function (exports, core, forms, menu, moment_, rxjs, coercion, snackBar, common, button, card, dialog, formField, gridList, icon, input, slider, toolbar, tooltip, angular2TextMask) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) { return e; } else {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
}
var moment___namespace = /*#__PURE__*/_interopNamespace(moment_);
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); };
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try {
step(generator.next(value));
}
catch (e) {
reject(e);
} }
function rejected(value) { try {
step(generator["throw"](value));
}
catch (e) {
reject(e);
} }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function () { if (t[0] & 1)
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
var __createBinding = Object.create ? (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
}) : (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
});
function __exportStar(m, o) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
__createBinding(o, m, p);
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
}
catch (error) {
e = { error: error };
}
finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
}
finally {
if (e)
throw e.error;
}
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
;
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n])
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try {
step(g[n](v));
}
catch (e) {
settle(q[0][3], e);
} }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
}
else {
cooked.raw = raw;
}
return cooked;
}
;
var __setModuleDefault = Object.create ? (function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function (o, v) {
o["default"] = v;
};
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
(function (DateFormat) {
DateFormat["ddMMyyyy"] = "ddMMyyyy";
DateFormat["MMddyyyy"] = "MMddyyyy";
DateFormat["yyyyMMdd"] = "yyyyMMdd";
DateFormat["yyyyddMM"] = "yyyyddMM";
})(exports.DateFormat || (exports.DateFormat = {}));
(function (DateType) {
DateType[DateType["AD"] = 1] = "AD";
DateType[DateType["BS"] = 2] = "BS";
})(exports.DateType || (exports.DateType = {}));
(function (Language) {
Language[Language["English"] = 0] = "English";
Language[Language["Nepali"] = 1] = "Nepali";
})(exports.Language || (exports.Language = {}));
(function (CalendarViewType) {
CalendarViewType[CalendarViewType["Both"] = 1] = "Both";
CalendarViewType[CalendarViewType["Year"] = 2] = "Year";
CalendarViewType[CalendarViewType["Month"] = 3] = "Month";
})(exports.CalendarViewType || (exports.CalendarViewType = {}));
(function (EFrequencyIn) {
EFrequencyIn[EFrequencyIn["InDays"] = 1] = "InDays";
EFrequencyIn[EFrequencyIn["InMonth"] = 2] = "InMonth";
EFrequencyIn[EFrequencyIn["InWeek"] = 3] = "InWeek";
})(exports.EFrequencyIn || (exports.EFrequencyIn = {}));
var Month = /** @class */ (function () {
function Month() {
}
return Month;
}());
var Day = /** @class */ (function () {
function Day() {
}
return Day;
}());
var 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
var 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' }];
var CalendarService = /** @class */ (function () {
function CalendarService() {
}
CalendarService.prototype.GetBSMonthList = function () {
var 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;
};
CalendarService.prototype.getFiscalYear = function (date) {
var bsDate = this.GetDateBS(date, exports.DateFormat.MMddyyyy);
var bsMonth = this.GetBSMonth(bsDate, exports.DateFormat.MMddyyyy);
var bsYear = this.GetBSYear(bsDate, exports.DateFormat.MMddyyyy);
var 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;
};
CalendarService.prototype.GetADMonthList = function () {
var 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;
};
CalendarService.prototype.GetBSMonthName = function (monthId) {
var monthname = this.GetBSMonthList().filter(function (x) { return x.id === monthId; });
if (monthname.length > 0) {
return monthname[0].month;
}
else {
return null;
}
};
CalendarService.prototype.GetADMonthName = function (monthId) {
var monthname = this.GetADMonthList().filter(function (x) { return x.id === monthId; });
if (monthname.length > 0) {
return monthname[0].month;
}
else {
return null;
}
};
CalendarService.prototype.GetWeekDayName = function (dayId) {
var weekDay = this.GetWeekDayNameList().filter(function (x) { return x.id === dayId; });
if (weekDay.length > 0) {
return weekDay[0].day;
}
else {
return null;
}
};
CalendarService.prototype.GetWeekDayNameList = function () {
var 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;
};
CalendarService.prototype.GetWeekDayPrefixList = function () {
var 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;
};
CalendarService.prototype.GetBSYearCal = function (NYear) {
var bsMonthList = [];
var selectedNDateD = NDateD.filter(function (x) { return x.NYear === NYear; })[0];
var 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;
};
CalendarService.prototype.GetBSDay = function (bsDate, df) {
var result;
var 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;
};
CalendarService.prototype.GetBSMonth = function (bsDate, df) {
var result;
var 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;
};
CalendarService.prototype.GetBSYear = function (bsDate, df) {
var result;
var 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;
};
CalendarService.prototype.GetMaxYear = function () {
return Math.max.apply(Math, BSADCal.map(function (o) { return o.NYear; }));
};
CalendarService.prototype.GetMinYear = function () {
return Math.min.apply(Math, BSADCal.map(function (o) { return o.NYear; }));
};
CalendarService.prototype.GetDateBS = function (adDate, df) {
if (!adDate) {
return null;
}
adDate = new Date(adDate);
var startDate;
var bsYear;
var bsMonth;
var bsDay;
adDate = new Date(adDate.getFullYear(), adDate.getMonth(), adDate.getDate());
try {
startDate = new Date(BSADCal.filter(function (x) { return new Date(x.EndDate) >= adDate && new Date(x.StartDate) <= adDate; })[0].StartDate);
bsYear = BSADCal.filter(function (x) { return new Date(x.EndDate) >= adDate && new Date(x.StartDate) <= adDate; })[0].NYear;
var totalDays_1 = this.GetDateDiff(adDate, startDate) + 1;
bsMonth = this.GetBSYearCal(bsYear).filter(function (x) { return x.Days >= totalDays_1; })[0].Month;
var dyList = this.GetBSYearCal(bsYear).filter(function (x) { return x.Days < totalDays_1; }).reverse()[0];
if (dyList) {
bsDay = dyList.Days;
}
bsDay = totalDays_1 - (bsDay === undefined ? 0 : bsDay);
}
catch (e) {
return null;
}
return this.GetFormatedDateBS(bsYear, bsMonth, bsDay, df);
};
CalendarService.prototype.GetDateAD = function (bsYear, bsMonth, bsDay) {
var adDate = new Date();
var totalDays = 0;
var ndateD = NDateD.filter(function (x) { return 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(function (x) { return x.NYear === bsYear; })[0].StartDate);
var listMonth = this.GetBSYearCal(bsYear).filter(function (x) { return 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;
};
CalendarService.prototype.GetDateADByDateBS = function (bsDate, df) {
var adDate;
var totalDays = 0;
var bsYear = this.GetBSYear(bsDate, df);
var bsMonth = this.GetBSYear(bsDate, df);
var bsDay = this.GetBSYear(bsDate, df);
if (NDateD.filter(function (x) { return x.NYear; }).length === 0 &&
bsMonth < 1 && bsMonth > 12 &&
this.GetDaysInMonthBS(bsYear, bsMonth) < bsDay) {
return null;
}
adDate = new Date(BSADCal.filter(function (x) { return x.NYear === bsYear; })[0].StartDate);
totalDays = this.GetBSYearCal(bsYear).filter(function (x) { return x.Month === bsMonth; })[0].Days;
totalDays = totalDays + bsDay - 1;
totalDays = (totalDays * 24 * 3600 * 1000);
totalDays += adDate.getTime();
adDate.setTime(totalDays);
return adDate;
};
CalendarService.prototype.GetDateADOfMonthStartEnd = function (bsDate, isStart, df) {
var bsYear = this.GetBSYear(bsDate, df);
var bsMonth = this.GetBSMonth(bsDate, df);
var bsDay = this.GetBSDay(bsDate, df);
var daysInMonth = 0;
var 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;
};
CalendarService.prototype.GetDaysInMonthBS = function (bsYear, bsMonth) {
switch (bsMonth) {
case 1:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M1;
case 2:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M2;
case 3:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M3;
case 4:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M4;
case 5:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M5;
case 6:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M6;
case 7:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M7;
case 8:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M8;
case 9:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M9;
case 10:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M10;
case 11:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M11;
case 12:
return NDateD.filter(function (x) { return x.NYear === bsYear; })[0].M12;
default:
return 0;
}
};
CalendarService.prototype.GetDaysInMonthAD = function (adYear, adMonth) {
var daysInMonth;
var adDate = new Date(adYear, adMonth, 1);
var date1 = adDate;
date1.setDate(1 - date1.getDate());
var date2 = adDate;
date2.setDate(1 - date2.getDate());
daysInMonth = (1 + this.GetDateAdd(date2, adDate)) - this.GetDateAdd(date1, adDate);
return daysInMonth;
};
CalendarService.prototype.getFormatedDate = function (dateAD, option) {
var result;
if (option.userSelectedFormat) {
if (option.userSelectedFormat === 1) {
option.dtFormat = exports.DateFormat.ddMMyyyy;
}
else if (option.userSelectedFormat === 2) {
option.dtFormat = exports.DateFormat.MMddyyyy;
}
else if (option.userSelectedFormat === 3) {
option.dtFormat = exports.DateFormat.yyyyMMdd;
}
else if (option.userSelectedFormat === 4) {
option.dtFormat = exports.DateFormat.yyyyddMM;
}
}
if (!option.dtFormat) {
option.dtFormat = exports.DateFormat.ddMMyyyy;
}
if (!option.dateType) {
option.dateType = exports.DateType.AD;
}
if (dateAD) {
if (option.dateType === exports.DateType.AD) {
result = this.GetFormatedDateAD(dateAD, option.dtFormat);
}
else {
result = this.GetDateBS(dateAD, option.dtFormat);
}
}
else {
result = 'undefined';
}
return result;
};
CalendarService.prototype.GetFormatedDateAD = function (adDate, dtFormat) {
adDate = new Date(adDate);
// console.log(adDate)
var yy = adDate.getFullYear().toString();
var mm = (adDate.getMonth() + 1 < 10) ? '0' + (adDate.getMonth() + 1).toString() : (adDate.getMonth() + 1).toString();
var 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;
}
};
CalendarService.prototype.GetFormatedDateBS = function (bsYear, bsMonth, bsDay, dtFormat) {
var yy = bsYear.toString();
var mm = (bsMonth < 10) ? '0' + bsMonth : bsMonth.toString();
var 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;
}
};
CalendarService.prototype.getFormatedDateLong = function (value, dtFormat, dtType) {
if (value && value.length == 10) {
value = value.substr(0, 10);
var yr = this.GetBSYear(value, dtFormat);
var mn = this.GetBSMonth(value, dtFormat);
var dy = this.GetBSDay(value, dtFormat);
var monthName = '';
if (dtType === exports.DateType.BS) {
var monthList = this.GetBSMonthList();
monthName = monthList[mn - 1].month;
}
else {
var monthList = this.GetADMonthList();
monthName = monthList[mn - 1].month;
}
return dy + " " + monthName + " " + yr;
}
else {
return "Calendar not found!";
}
};
CalendarService.prototype.getLongDateString = function (val) {
var 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;
};
CalendarService.prototype.GetDaysInYear = function (bsYear) {
var totalDays = 0;
NDateD.filter(function (x) { return x.NYear < bsYear; }).forEach(function (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;
};
CalendarService.prototype.GetDateAdd = function (date1, date2) {
var timeAdd = date2.getTime() + date1.getTime();
return Math.ceil(Math.abs(timeAdd / (1000 * 3600 * 24)));
};
CalendarService.prototype.GetDateDiff = function (date1, date2) {
var timeDiff = date2.getTime() - date1.getTime();
return Math.ceil(Math.abs(timeDiff / (1000 * 3600 * 24)));
};
CalendarService.prototype.addYearInBS = function (bsDate, addYear, df) {
var year = this.GetBSYear(bsDate, df);
var month = this.GetBSMonth(bsDate, df);
var day = this.GetBSDay(bsDate, df);
var 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);
};
return CalendarService;
}());
CalendarService.decorators = [
{ type: core.Injectable }
];
CalendarService.ctorParameters = function () { return []; };
var CalendarErrorStateMatcher = /** @class */ (function () {
function CalendarErrorStateMatcher() {
}
CalendarErrorStateMatcher.prototype.isErrorState = function (control, form) {
if (control.value && control.value.toString().includes("_")) {
return true;
}
var isSubmitted = form && form.submitted;
return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted));
};
return CalendarErrorStateMatcher;
}());
var 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!', 'अन्तिम गते शुरू गते भन्दा कम हुनु भएन।']
};
var moment = moment___namespace;
var DateComponent = /** @class */ (function () {
function DateComponent(dpService, snackbar, controlDir) {
var _this = this;
this.dpService = dpService;
this.snackbar = snackbar;
this.controlDir = controlDir;
this.onDateChanged = new core.EventEmitter();
this.matcher = new CalendarErrorStateMatcher();
this.dateFormat = exports.DateFormat.ddMMyyyy;
this.datemask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
this.stateChanges = new rxjs.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: exports.DateType.AD, dateFormatAD: exports.DateFormat.ddMMyyyy, dateFormatBS: exports.DateFormat.yyyyMMdd };
this.propagateChange = function (_) {
};
this.onTouched = function () { };
this.onBlur = function (event) {
if (event.target.value === "" || event.target.value.toString().includes("_")) {
_this.setDateValueByString(event.target.value, _this.dateFormat, _this._param.dateType);
}
};
this.formControl = new forms.FormControl();
controlDir.valueAccessor = this;
this.caption = label;
}
Object.defineProperty(DateComponent.prototype, "param", {
get: function () {
return this._param;
},
set: function (val) {
this._param = JSON.parse(val);
this.changeDateFormat(this._param.dateType, this._param.dateType === exports.DateType.AD ? this._param.dateFormatAD : this._param.dateFormatBS);
this.setValue(false, false);
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "required", {
get: function () {
return this._required;
},
// @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: function (val) {
this._required = coercion.coerceBooleanProperty(val);
},
enumerable: false,
configurable: true
});
DateComponent.prototype.pushTimeMask = function (mask) {
mask.push(' ');
mask.push(/\d/);
mask.push(/\d/);
mask.push(':');
mask.push(/\d/);
mask.push(/\d/);
return mask;
};
DateComponent.prototype.changeDateFormat = function (dType, val) {
if (!val) {
if (dType === exports.DateType.AD) {
val = this._param.dateFormatAD;
}
else {
val = this._param.dateFormatBS;
}
}
var mask;
if (dType === exports.DateType.AD) {
if (val === exports.DateFormat.MMddyyyy || val === exports.DateFormat.ddMMyyyy) {
mask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/];
}
else {
mask = [/\d/, /\d/, /\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/];
}
}
else {
if (val === exports.DateFormat.MMddyyyy || val === exports.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) {
var mask1 = __spread(mask);
var mask2 = __spread(mask);
var seperator = [' ', '|', ' '];
this.datemask = __spread(mask1, seperator, mask2);
}
else {
this.datemask = __spread(mask);
}
this.dateFormat = val;
};
Object.defineProperty(DateComponent.prototype, "withTime", {
get: function () {
return this._withTime;
},
set: function (val) {
this._withTime = coercion.coerceBooleanProperty(val);
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "placeholder", {
get: function () {
return this._placeholder;
},
set: function (val) {
this._placeholder = val;
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "readonly", {
get: function () {
return this._readonly;
},
// @Input() set showCalendarOnFocus(val: boolean) {
// this._showCalendarOnFocus = val;
// } get showCalendarOnFocus(): boolean {
// return this._showCalendarOnFocus;
// }
set: function (val) {
this._readonly = coercion.coerceBooleanProperty(val);
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "closeOnClick", {
get: function () {
return this._closeOnClick;
},
set: function (val) {
this._closeOnClick = coercion.coerceBooleanProperty(val);
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "disabled", {
get: function () {
return this.formControl.disabled;
},
set: function (val) {
this.setDisabledState(coercion.coerceBooleanProperty(val));
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "isRange", {
get: function () {
return this._isRange;
},
set: function (val) {
this._isRange = coercion.coerceBooleanProperty(val);
this.changeDateFormat(this._param.dateType);
},
enumerable: false,
configurable: true
});
Object.defineProperty(DateComponent.prototype, "language", {
get: function () {
return this._language;
},
set: function (val) {
this._language = val;
},
enumerable: false,
configurable: true
});
// 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
DateComponent.prototype.registerOnChange = function (fn) {
this.propagateChange = fn;
};
DateComponent.prototype.writeValue = function (value) {
// const val = new Date(value);
this.dateObject = [];
this.manualChanged = true;
this.setDateValueByDate(value);
this.formControl.markAsUntouched();
};
DateComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
DateComponent.prototype.setDisabledState = function (isDisabled) {
if (isDisabled) {
this.formControl.disable();
}
else {
this.formControl.enable();
}
};
//end controlValueAccsor
DateComponent.prototype.setDateValueByDate = function (value) {
// let date = value;
if (!value) {
this.setValue(true, true);
return;
}
var timeString = "";
var h, m;
var FORMAT_DATE = moment.defaultFormat;
this.changeDateFormat(this._param.dateType);
if (this.isRange) {
var formatedStartDateAD = '';
var formatedStartDateBS = '';
var formatedEndDateAD = '';
var formatedEndDateBS = '';
if (value && value.start) {
var startDate = moment(value.start, FORMAT_DATE);
var 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 {
var 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);
var dtAD = this.withTime ? this.dpService.GetFormatedDateAD(value, this._param.dateFormatAD) + " " + timeString : "" + this.dpService.GetFormatedDateAD(value, this._param.dateFormatAD);
var 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);
};
DateComponent.prototype.setDateValueByString = function (dtValue, dtFormat, dtType) {
var _this = this;
if ((dtValue.toString().includes("_")) || (dtValue.toString() === "")) {
this.dateObject = [];
this.execPropagateChange(null);
return;
}
var givenArray = dtValue.split(' | ');
var loop = 0;
givenArray.forEach(function (element) {
var lineArray = element.split(" ");
var dateString = lineArray[0];
var splitedDate = dateString.split("-");
var timeString = "";
var yr;
var mn;
var dy;
var hr = 0;
var mu = 0;
if (dtFormat === exports.DateFormat.MMddyyyy) {
yr = +splitedDate[2];
mn = +splitedDate[0];
dy = +splitedDate[1];
}
else if (dtFormat === exports.DateFormat.ddMMyyyy) {
yr = +splitedDate[2];
mn = +splitedDate[1];
dy = +splitedDate[0];
}
else if (dtFormat === exports.DateFormat.yyyyddMM) {
yr = +splitedDate[0];
mn = +splitedDate[2];
dy = +splitedDate[1];
}
else if (dtFormat === exports.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) {
var 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;
}
var strHr = (hr < 10) ? '0' + hr : hr.toString();
var strMn = (mu < 10) ? '0' + mu : mu.toString();
timeString = " " + strHr + ":" + strMn;
}
if (dtType === exports.DateType.AD) {
var newDate = new Date(yr, mn - 1, dy, hr, mu);
var dtAD = "" + _this.dpService.GetFormatedDateAD(newDate, _this._param.dateFormatAD) + timeString;
var dtBS = _this.dpService.GetDateBS(newDate, _this._param.dateFormatBS);
_this.setDateObject(loop, newDate, dtBS ? "" + dtBS + timeString : '', dtAD, dtType);
}
else {
var newDate = _this.dpService.GetDateAD(yr, mn, dy);
if (newDate === null) {
_this.execPropagateChange(null);
_this.errorMessage = _this.language === 0 ? 'BS Calendar not match!' : 'नेपाली क्यालेन्डर अनुसार गते मिलेन।';
return;
}
else {
var dtAD = "" + _this.dpService.GetFormatedDateAD(newDate, _this._param.dateFormatAD) + timeString;
var 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);
}
};
DateComponent.prototype.setDateObject = function (index, dt, dtBS, dtAD, dtType) {
if (index === 0) {
this.dateObject = [];
}
this.dateObject.push({
date: dt,
dateAD: dtAD,
dateBS: dtBS,
selectedDateType: dtType
});
};
DateComponent.prototype.onManualChange = function (event) {
// if(this.readonly){
// return
// }
var 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 === exports.DateType.AD ? this.dateObject[0].dateAD : this.dateObject[0].dateBS)) {
this.setDateValueByString(newValue, this.dateFormat, this._param.dateType);
}
}
else {
if (newValue !== (this._param.dateType === exports.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();
}
}
};
DateComponent.prototype.emitChange = function (withToolTip) {
//console.log(withToolTip)
if (this.formControl.value !== this.lastEmitted) {
var 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;
}
};
DateComponent.prototype.execPropagateChange = function (obj, isDateTypeChanged, withToolTip) {
if (isDateTypeChanged === void 0) { isDateTypeChanged = false; }
if (withToolTip === void 0) { 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 === exports.DateType.BS) {
this.errorMessage = "Date must between \n " + this.dpService.GetDateBS(this.controlDir.control["minDate"], this._param.dateFormatBS) + " \n and\n " + this.dpService.GetDateBS(this.controlDir.control["maxDate"], this._param.dateFormatBS) + " \n ";
}
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);
}
};
DateComponent.prototype.ngOnInit = function () {
};
DateComponent.prototype.ngOnDestroy = function () {
this.stateChanges.complete();
};
DateComponent.prototype.clearText = function () {
this.formControl.setValue('');
this.dateObject = [];
this.execPropagateChange(null);
};
DateComponent.prototype.setValue = function (initial, withToolTip) {
// if(this.readonly){return}
if (this.dateObject.length > 0) {
var startDate = this._param.dateType === exports.DateType.AD ? "" + this.dateObject[0].dateAD : "" + this.dateObject[0].dateBS;
var 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 === exports.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);
}
};
DateComponent.prototype.changeDateType = function () {
if (this._param.dateType === exports.DateType.AD) {
this._param.dateType = exports.DateType.BS;
}
else {
this._param.dateType = exports.DateType.AD;
}
this.changeDateFormat(this._param.dateType, this._param.dateType === exports.DateType.AD ? this._param.dateFormatAD : this._param.dateFormatBS);
this.setValue(false, false);
};
DateComponent.prototype.showPicker = function () {
if (this.isPickerVisible) {
return;
}
this.isPickerVisible = true;
var 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();
};
DateComponent.prototype.setTooltip = function () {
var result = '';
if (this.dateObject && this.dateObject.length > 0) {
if (this.isRange) {
var ad = "AD: " + this.dpService.getFormatedDateLong(this.dateObject[0].dateAD, this._param.dateFormatAD, exports.DateType.AD) + " to " + this.dpService.getFormatedDateLong(this.dateObject[1].dateAD, this._param.dateFormatAD, exports.DateType.AD) + " \n";
var bs = "BS: " + this.dpService.getFormatedDateLong(this.dateObject[0].dateBS, this._param.dateFormatBS, exports.DateType.BS) + " to " + this.dpService.getFormatedDateLong(this.dateObject[1].dateBS, this._param.dateFormatBS, exports.DateType.BS) + " \n";
if (this._param.dateType === exports.DateType.AD) {
result = ad + " " + bs;
}
else {
result = bs + " " + ad;
}
}
else {
var ad = "AD: " + this.dpService.getFormatedDateLong(this.dateObject[0].dateAD, this._param.dateFormatAD, exports.DateType.AD) + " \n";
var bs = "BS: " + this.dpService.getFormatedDateLong(this.dateObject[0].dateBS, this._param.dateFormatBS, exports.DateType.BS) + " \n";
var 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 === exports.DateType.AD) {
result = ad + " " + bs + " \n Date: " + longDateString;
}
else {
result = bs + " " + ad + " \n Date: " + longDateString;
}
}
}
else {
result = "Display Type: " + (this._param.dateType === exports.DateType.AD ? this.caption.AD[this.language] + ', ' : this.caption.BS[this.language]);
result = result + " \n Format: " + this.dateFormat;
}
this.tooltipText = result;
};
DateComponent.prototype.dateChangedFromPopUp = function (result) {
var _this = this;
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);
}
var index_1 = 0;
if (!this.isRange) {
if (this._param.dateType === exports.DateType.AD) {
this.formControl.setValue(result[0].dateAD);
}
else {
this.formControl.setValue(result[0].dateBS);
}
}
else {
if (this._param.dateType === exports.DateType.AD) {
this.formControl.setValue(result[0].dateAD + " | " + result[1].dateAD);
}
else {
this.formControl.setValue(result[0].dateBS + " | " + result[1].dateBS);
}
}
result.forEach(function (el) {
_this.setDateObject(index_1, el.date, el.dateBS, el.dateAD, el.selectedDateType);
index_1++;
});
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();
}
}
};
DateComponent.prototype.onMenuClosed = function () {
this.isPickerVisible = false;
this.dateInput.nativeElement.focus();
};
return DateComponent;
}());
DateComponent.decorators = [
{ type: core.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: core.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 = function () { return [
{ type: CalendarService },
{ type: snackBar.MatSnackBar },
{ type: forms.NgControl, decorators: [{ type: core.Self }, { type: core.Optional }] }
]; };
DateComponent.propDecorators = {
calPopUp: [{ type: core.ViewChild, args: ['calPopUp', { static: false },] }],
menuTrigger: [{ type: core.ViewChild, args: [menu.MatMenuTrigger, { static: false },] }],
dateInput: [{ type: core.ViewChild, args: ["dateInput", { static: true },] }],
elTooltip: [{ type: core.ViewChild, args: ["tooltip",] }],
onDateChanged: [{ type: core.Output }],
param: [{ type: core.Input }],
required: [{ type: core.Input }],
withTime: [{ type: core.Input }],
placeholder: [{ type: core.Input }],
readonly: [{ type: core.Input }],
closeOnClick: [{ type: core.Input }],
disabled: [{ type: core.Input }],
isRange: [{ type: core.Input }],
language: [{ type: core.Input }]
};
var CalendarComponent = /** @class */ (function () {
function CalendarComponent(dpService) {
this.dpService = dpService;
this.DateTimeChanged = new core.EventEmitter();
this.day = 1;
this.currentView = exports.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 = exports.DateType.AD;
this.dateFormatAD = exports.DateFormat.ddMMyyyy;
this.dateFormatBS = exports.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();
}
Object.defineProperty(CalendarComponent.prototype, "content", {
set: function (content) {
this.yearMonth = content;
},
enumerable: false,
configurable: true
});
Object.defineProperty(CalendarComponent.prototype, "dateRange", {
get: function () {
return this.defaultDateRange;
},
set: function (val) {
this.defaultDateRange = val;
},
enumerable: false,
configurable: true
});
CalendarComponent.prototype.showCalendar = function (dateType, dateFormatAD, dateFormatBS, withTime, minDate, maxDate, closeOnClick, currentDate, lang) {
var _this = this;
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(function () {
_this.yearMonth.focus();
}, 100);
};
CalendarComponent.prototype.setInitialCalendar = function (val) {
if (this.dateType === exports.DateType.AD) {
var 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 {
var 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();
}
};
CalendarComponent.prototype.dateTypeToggle = function () {
if (this.dateType === exports.DateType.AD) {
this.dateType = exports.DateType.BS;
}
else {
this.dateType = exports.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();
};
Object.defineProperty(CalendarComponent.prototype, "selectedDate", {
get: function () {
if (this.defaultSelectedDate === null) {
this.setDate();
}
return this.defaultSelectedDate;
},
enumerable: false,
configurable: true
});
CalendarComponent.prototype.setCalender = function () {
if (this.dateType === exports.DateType.AD) {
var 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, exports.DateType.AD, this.maxDate, this.minDate);
}
else {
var 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, exports.DateType.BS, this.maxDate, this.minDate);
}
this.setDate();
this.settime();
};
CalendarComponent.prototype.setCalendarDay = function (year, month, day, dType, maxDate, minDate) {
var today = new Date(new Date().toDateString());
var dayList = this.dpService.GetWeekDayPrefixList();
this.cols = 7;
this.rowHeight = '35px';
this.currentView = exports.CalendarViewType.Both;
this.datas = [];
this.titles = [];
this.month = month;
this.year = year;
// tslint:disable-next-line:prefer-for-of
for (var 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 === exports.DateType.AD) {
// this.dateType = 'AD';
this.title = this.dpService.GetADMonthName(month) + ', ' + year;
var d = new Date(year, month - 1, 1).getDay();
var dInm = new Date(year, month, 0).getDate();
if (d > 0) {
// tslint:disable-next-line:no-shadowed-variable
for (var i = 0; i < d; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
var curDate = void 0;
var disable = 'false';
var currentDate = new Date(this.currentDate);
var selDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
for (var 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: disable });
}
else if (curDate.getTime() === selDate.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.selectedColor, disable: disable });
}
else {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.backgroundColor, disable: disable });
}
}
for (var i = this.datas.length; i <= 41; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
else {
var 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;
}
var dInm = this.dpService.GetDaysInMonthBS(+year, +month);
var disable = 'false';
// var selDate: Date = this.dpService.GetDateAD(+year, +month, +day)
var currentDate = new Date(this.currentDate);
var selDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
if (d > 0) {
for (var i = 0; i < d; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
for (var i = 1; i <= dInm; i++) {
var 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: disable });
}
else if (curDate.getTime() === selDate.getTime()) {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.selectedColor, disable: disable });
}
else {
this.datas.push({ text: i, id: i, rows: 1, cols: 1, color: this.backgroundColor, disable: disable });
}
}
for (var i = this.datas.length; i <= 41; i++) {
this.datas.push({ text: '', id: 0, rows: 1, cols: 1, color: this.backgroundColor });
}
}
this.setDisplayDate();
};
CalendarComponent.prototype.setDisplayDate = function () {
var ad = new Date(this.selectedDate.date.getFullYear(), this.selectedDate.date.getMonth(), this.selectedDate.date.getDate());
var yr = this.selectedDate.date.getFullYear();
var mn = this.selectedDate.date.getMonth() + 1;
var dy = this.selectedDate.date.getDate();
var mnName = '';
if (this.dateType === exports.DateType.AD) {
var 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 === exports.DateType.AD) ? 'BS: ' : 'AD: ';
this.displayDate = this.displayDate + dy + ' ' + mnName + ' ' + yr;
};
CalendarComponent.prototype.setCalendarMonth = function (year, dType) {
var disable = 'false';
this.cols = 3;
this.rowHeight = this.withTime ? '70px' : '60px';
;
this.datas = [];
this.currentView = exports.CalendarViewType.Month;
var minYearMnth = this.minDate ? this.minDate.getFullYear().toString() : undefined;
var 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 === exports.DateType.BS) {
var 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();
var 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();
var mnth = (this.dpService.GetBSMonth(bs, this.dateFormatBS) - 1).toString();
maxYearMnth = maxYearMnth + (+mnth < 10 ? '0' + mnth.toString() : mnth.toString());
}
}
var monthList;
if (dType === exports.DateType.AD) {
monthList = this.dpService.GetADMonthList();
}
else {
monthList = this.dpService.GetBSMonthList();
}
var curYearMnth = '';
for (var 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: disable });
}
this.settime();
};
CalendarComponent.prototype.setCalendarYear = function (fromYear, toYear) {
var disable = 'false';
this.cols = 3;
this.rowHeight = this.withTime ? '70px' : '60px';
this.datas = [];
this.currentView = exports.CalendarViewType.Year;
var minYearMnth = this.minDate ? this.minDate.getFullYear() : undefined;
var maxYearMnth = this.maxDate ? this.maxDate.getFullYear() : undefined;
if (this.dateType === exports.DateType.BS) {
var 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 (var 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: disable });
}
this.settime();
};
CalendarComponent.prototype.settime = function () {
if (this.withTime) {
if (this.currentDate) {
this.hourValue = this.currentDate.getHours();
this.minuteValue = this.currentDate.getMinutes();
}
else {
this.hourValue = 0;
this.minuteValue = 0;
}
}
};
CalendarComponent.prototype.titleClick = function () {
if (this.currentView === exports.CalendarViewType.Both) {
this.currentView = exports.CalendarViewType.Month;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === exports.CalendarViewType.Month) {
this.currentView = exports.CalendarViewType.Year;
var 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);
}
};
CalendarComponent.prototype.upDown = function (ev) {
if (ev === '+') {
if (this.currentView === exports.CalendarViewType.Month) {
this.year = this.year - 1;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === exports.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 === exports.CalendarViewType.Both) {
if (this.month === 1) {
this.month = 12;
this.year = this.year - 1;
}
else {
this.month = this.month - 1;
}
if (this.dateType === exports.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 === exports.CalendarViewType.Month) {
this.year = this.year + 1;
this.title = this.year.toString();
this.setCalendarMonth(this.year, this.dateType);
}
else if (this.currentView === exports.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 === exports.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 === exports.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);
}
}
};
CalendarComponent.prototype.ItemClicked = function (ev) {
if (this.currentView === exports.CalendarViewType.Both) {
this.day = +ev;
var today = new Date(new Date().toDateString());
var curDate = new Date(this.year, this.month, 1);
var index = this.datas.findIndex(function (img) { return img.id === ev; });
if (this.dateType === exports.DateType.AD) {
for (var 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 (var 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 === exports.CalendarViewType.Year) {
this.currentView = exports.CalendarViewType.Month;
this.year = ev;
if (this.dateType === exports.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 === exports.CalendarViewType.Month) {
this.month = ev;
if (this.dateType === exports.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 = exports.CalendarViewType.Both;
this.setCalendarDay(this.year, this.month, 1, this.dateType, this.maxDate, this.minDate);
}
};
CalendarComponent.prototype.setDate = function () {
var dt;
if (this.dateType === exports.DateType.AD) {
dt = new Date(+this.year, +this.month - 1, +this.day);
}
else {
dt = this.dpService.GetDateAD(+this.year, +this.month, +this.day);
}
var dtAD = this.dpService.GetFormatedDateAD(dt, this.dateFormatAD);
var dtBS = null;
try {
dtBS = this.dpService.GetDateBS(dt, this.dateFormatBS);
}
catch (e) {
dtBS = '';
}
if (!!this.withTime) {
var hr = (+this.hourValue < 10) ? '0' + this.hourValue.toString() : this.hourValue.toString();
var 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;
};
CalendarComponent.prototype.returnDate = function () {
this.setDate();
this.setDisplayDate();
// if (this.closeOnClick) {
// if (!this.dateRange) {
// if (!this.withTime) {
this.DateTimeChanged.emit(this.defaultSelectedDate);
// }
// }
// }
};
CalendarComponent.prototype.onInputChange = function (ev, flag) {
if (flag === 'm') {
this.minuteValue = ev.value;
}
else {
this.hourValue = ev.value;
}
this.returnDate();
};
return CalendarComponent;
}());
CalendarComponent.decorators = [
{ type: core.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 = function () { return [
{ type: CalendarService }
]; };
CalendarComponent.propDecorators = {
content: [{ type: core.ViewChild, args: ['yearmonth', { static: false },] }],
DateTimeChanged: [{ type: core.Output }],
dateRange: [{ type: core.Input }]
};
var CalendarPopupComponent = /** @class */ (function () {
function CalendarPopupComponent() {
this.DateTimeChanged = new core.EventEmitter();
this.fromToTitle = 'From Date';
this.isFront = true;
this.className = '';
this.withTime = false;
this.dateType = exports.DateType.AD;
this.dateFormatAD = exports.DateFormat.ddMMyyyy;
this.dateFormatBS = exports.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();
}
Object.defineProperty(CalendarPopupComponent.prototype, "dateRange", {
get: function () {
return this.defaultDateRange;
},
set: function (val) {
this.defaultDateRange = val;
},
enumerable: false,
configurable: true
});
CalendarPopupComponent.prototype.showCalendar = function (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';
}
}
};
CalendarPopupComponent.prototype.ngOnInit = function () {
};
CalendarPopupComponent.prototype.revert = function () {
this.DateTimeChanged.emit(undefined);
};
CalendarPopupComponent.prototype.submit = function () {
var 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);
}
}
};
CalendarPopupComponent.prototype.datetimeChangedFrom = function (e) {
this.selectedFromDate = {
date: e.date,
dateAD: e.dateAD,
dateBS: e.dateBS,
selectedDateType: e.selectedDateType
};
if (this.dateRange === false) {
if (this.closeOnClick === true) {
var result = [
this.selectedFromDate
];
this.DateTimeChanged.emit(result);
return;
}
}
else {
if (this.closeOnClick === true) {
this.nextPanel();
}
}
};
CalendarPopupComponent.prototype.datetimeChangedTo = function (e) {
this.selectedToDate = {
date: e.date,
dateAD: e.dateAD,
dateBS: e.dateBS,
selectedDateType: e.selectedDateType
};
if (this.closeOnClick === true) {
var result = [this.selectedFromDate, this.selectedToDate];
this.DateTimeChanged.emit(result);
}
};
CalendarPopupComponent.prototype.nextPanel = function () {
if (this.lang === 0) {
this.fromToTitle = 'To Date';
}
else {
this.fromToTitle = 'सम्म';
}
if (this.selectedFromDate == null) {
this.selectedFromDate = this.cal1.selectedDate;
}
var 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;
};
CalendarPopupComponent.prototype.previousPanel = function () {
if (this.lang === 0) {
this.fromToTitle = 'From Date';
}
else {
this.fromToTitle = 'देखि';
}
this.selectedToDate = null;
this.isFront = !this.isFront;
};
return CalendarPopupComponent;
}());
CalendarPopupComponent.decorators = [
{ type: core.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 = function () { return []; };
CalendarPopupComponent.propDecorators = {
DateTimeChanged: [{ type: core.Output }],
cal1: [{ type: core.ViewChild, args: ['cal1', { static: false },] }],
cal2: [{ type: core.ViewChild, args: ['cal2', { static: false },] }],
card: [{ type: core.ViewChild, args: ['card', { static: false },] }],
dateRange: [{ type: core.Input }]
};
var NgxMatCalendarModule = /** @class */ (function () {
function NgxMatCalendarModule() {
}
return NgxMatCalendarModule;
}());
NgxMatCalendarModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [DateComponent, CalendarComponent, CalendarPopupComponent],
imports: [
common.CommonModule,
input.MatInputModule,
dialog.MatDialogModule,
toolbar.MatToolbarModule,
icon.MatIconModule,
card.MatCardModule,
snackBar.MatSnackBarModule,
gridList.MatGridListModule,
formField.MatFormFieldModule,
button.MatButtonModule,
slider.MatSliderModule,
menu.MatMenuModule,
tooltip.MatTooltipModule,
forms.FormsModule,
forms.ReactiveFormsModule,
angular2TextMask.TextMaskModule,
],
exports: [DateComponent],
providers: [CalendarService]
},] }
];
var moment$1 = moment___namespace;
// @dynamic
var DateValidators = /** @class */ (function () {
function DateValidators() {
}
DateValidators.dateMinimum = function (date) {
return function (control) {
control["minDate"] = date;
if (control.value == null) {
return null;
}
var FORMAT_DATE = 'YYYY-MM-DD';
var controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
var 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)
}
};
};
};
DateValidators.dateMaximum = function (date) {
return function (control) {
control["maxDate"] = date;
if (control.value == null) {
return null;
}
var FORMAT_DATE = 'YYYY-MM-DD';
var controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
var 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)
}
};
};
};
DateValidators.dateBetween = function (startDate, endDate) {
return function (control) {
control["maxDate"] = endDate;
control["minDate"] = startDate;
var FORMAT_DATE = 'YYYY-MM-DD';
if (control.value == null) {
return null;
}
var validationStartDate = moment$1(startDate, FORMAT_DATE);
var validationEndDate = moment$1(endDate, FORMAT_DATE);
if (control.value.start) {
var controlStartDate = moment$1(control.value.start, FORMAT_DATE);
var controlEndDate = moment$1(control.value.end, FORMAT_DATE);
if (!controlStartDate.isValid()) {
return null;
}
if (!controlEndDate.isValid()) {
return null;
}
if (controlStartDate.isSame(controlEndDate, 'day')) {
var isSameOrAfter = controlStartDate.isSameOrAfter(validationStartDate, 'day');
var 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 {
var sameMin = controlStartDate.isSameOrAfter(validationStartDate, 'day') && controlStartDate.isSameOrBefore(validationEndDate, 'day');
var sameMax = controlEndDate.isSameOrAfter(validationStartDate, 'day') && controlEndDate.isSameOrBefore(validationEndDate, 'day');
if (sameMax && sameMin) {
return null;
}
var isStartDateInRange = controlStartDate.isBetween(validationStartDate, validationEndDate);
var 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 {
var controlDate = moment$1(control.value, FORMAT_DATE);
if (!controlDate.isValid()) {
return null;
}
var sameMin = controlDate.isSame(validationStartDate, 'day');
if (sameMin) {
return null;
}
var 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)
}
};
}
};
};
return DateValidators;
}());
/*
* Public API Surface of ngx-mat-calendar
*/
/**
* Generated bundle index. Do not edit.
*/
exports.CalendarService = CalendarService;
exports.DateComponent = DateComponent;
exports.DateValidators = DateValidators;
exports.Day = Day;
exports.Month = Month;
exports.NgxMatCalendarModule = NgxMatCalendarModule;
exports.ɵa = CalendarComponent;
exports.ɵb = CalendarPopupComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-mat-calendar.umd.js.map