@icap-ethiopia/esm-ethiohri-app
Version:
A microfrontend ethiohri OpenMRS
616 lines (615 loc) • 18.2 kB
JavaScript
!(function (a) {
"use strict";
function b() {
(this.regionalOptions = []),
(this.regionalOptions[""] = {
invalidCalendar: "Calendar {0} not found",
invalidDate: "Invalid {0} date",
invalidMonth: "Invalid {0} month",
invalidYear: "Invalid {0} year",
differentCalendars: "Cannot mix {0} and {1} dates",
}),
(this.local = this.regionalOptions[""]),
(this.calendars = {}),
(this._localCals = {});
}
function c(b, c, d, e) {
if (
((this._calendar = b),
(this._year = c),
(this._month = d),
(this._day = e),
0 === this._calendar._validateLevel &&
!this._calendar.isValid(this._year, this._month, this._day))
)
throw (
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
).replace(/\{0\}/, this._calendar.local.name);
}
function d(a, b) {
return (a = "" + a), "000000".substring(0, b - a.length) + a;
}
function e() {
this.shortYearCutoff = "+10";
}
function f(a) {
this.local = this.regionalOptions[a] || this.regionalOptions[""];
}
a.extend(b.prototype, {
instance: function (a, b) {
(a = (a || "gregorian").toLowerCase()), (b = b || "");
var c = this._localCals[a + "-" + b];
if (
(!c &&
this.calendars[a] &&
((c = new this.calendars[a](b)), (this._localCals[a + "-" + b] = c)),
!c)
)
throw (
this.local.invalidCalendar || this.regionalOptions[""].invalidCalendar
).replace(/\{0\}/, a);
return c;
},
newDate: function (a, b, c, d, e) {
return (
(d =
(void 0 !== a && null !== a && a.year
? a.calendar()
: "string" == typeof d
? this.instance(d, e)
: d) || this.instance()),
d.newDate(a, b, c)
);
},
substituteDigits: function (a) {
return function (b) {
return (b + "").replace(/[0-9]/g, function (b) {
return a[b];
});
};
},
substituteChineseDigits: function (a, b) {
return function (c) {
for (var d = "", e = 0; c > 0; ) {
var f = c % 10;
(d = (0 === f ? "" : a[f] + b[e]) + d), e++, (c = Math.floor(c / 10));
}
return 0 === d.indexOf(a[1] + b[1]) && (d = d.substr(1)), d || a[0];
};
},
}),
a.extend(c.prototype, {
newDate: function (a, b, c) {
return this._calendar.newDate(
void 0 === a || null === a ? this : a,
b,
c
);
},
year: function (a) {
return 0 === arguments.length ? this._year : this.set(a, "y");
},
month: function (a) {
return 0 === arguments.length ? this._month : this.set(a, "m");
},
day: function (a) {
return 0 === arguments.length ? this._day : this.set(a, "d");
},
date: function (b, c, d) {
if (!this._calendar.isValid(b, c, d))
throw (
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
).replace(/\{0\}/, this._calendar.local.name);
return (this._year = b), (this._month = c), (this._day = d), this;
},
leapYear: function () {
return this._calendar.leapYear(this);
},
epoch: function () {
return this._calendar.epoch(this);
},
formatYear: function () {
return this._calendar.formatYear(this);
},
monthOfYear: function () {
return this._calendar.monthOfYear(this);
},
weekOfYear: function () {
return this._calendar.weekOfYear(this);
},
daysInYear: function () {
return this._calendar.daysInYear(this);
},
dayOfYear: function () {
return this._calendar.dayOfYear(this);
},
daysInMonth: function () {
return this._calendar.daysInMonth(this);
},
dayOfWeek: function () {
return this._calendar.dayOfWeek(this);
},
weekDay: function () {
return this._calendar.weekDay(this);
},
extraInfo: function () {
return this._calendar.extraInfo(this);
},
add: function (a, b) {
return this._calendar.add(this, a, b);
},
set: function (a, b) {
return this._calendar.set(this, a, b);
},
compareTo: function (b) {
if (this._calendar.name !== b._calendar.name)
throw (
a.calendars.local.differentCalendars ||
a.calendars.regionalOptions[""].differentCalendars
)
.replace(/\{0\}/, this._calendar.local.name)
.replace(/\{1\}/, b._calendar.local.name);
var c =
this._year !== b._year
? this._year - b._year
: this._month !== b._month
? this.monthOfYear() - b.monthOfYear()
: this._day - b._day;
return 0 === c ? 0 : c < 0 ? -1 : 1;
},
calendar: function () {
return this._calendar;
},
toJD: function () {
return this._calendar.toJD(this);
},
fromJD: function (a) {
return this._calendar.fromJD(a);
},
toJSDate: function () {
return this._calendar.toJSDate(this);
},
fromJSDate: function (a) {
return this._calendar.fromJSDate(a);
},
toString: function () {
return (
(this.year() < 0 ? "-" : "") +
d(Math.abs(this.year()), 4) +
"-" +
d(this.month(), 2) +
"-" +
d(this.day(), 2)
);
},
}),
a.extend(e.prototype, {
_validateLevel: 0,
newDate: function (b, d, e) {
return void 0 === b || null === b
? this.today()
: (b.year &&
(this._validate(
b,
d,
e,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
),
(e = b.day()),
(d = b.month()),
(b = b.year())),
new c(this, b, d, e));
},
today: function () {
return this.fromJSDate(new Date());
},
epoch: function (b) {
return this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidYear ||
a.calendars.regionalOptions[""].invalidYear
).year() < 0
? this.local.epochs[0]
: this.local.epochs[1];
},
formatYear: function (b) {
var c = this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidYear ||
a.calendars.regionalOptions[""].invalidYear
);
return (c.year() < 0 ? "-" : "") + d(Math.abs(c.year()), 4);
},
monthsInYear: function (b) {
return (
this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidYear ||
a.calendars.regionalOptions[""].invalidYear
),
12
);
},
monthOfYear: function (b, c) {
var d = this._validate(
b,
c,
this.minDay,
a.calendars.local.invalidMonth ||
a.calendars.regionalOptions[""].invalidMonth
);
return (
((d.month() + this.monthsInYear(d) - this.firstMonth) %
this.monthsInYear(d)) +
this.minMonth
);
},
fromMonthOfYear: function (b, c) {
var d =
((c + this.firstMonth - 2 * this.minMonth) % this.monthsInYear(b)) +
this.minMonth;
return (
this._validate(
b,
d,
this.minDay,
a.calendars.local.invalidMonth ||
a.calendars.regionalOptions[""].invalidMonth
),
d
);
},
daysInYear: function (b) {
var c = this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidYear ||
a.calendars.regionalOptions[""].invalidYear
);
return this.leapYear(c) ? 366 : 365;
},
dayOfYear: function (b, c, d) {
var e = this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
);
return (
e.toJD() -
this.newDate(
e.year(),
this.fromMonthOfYear(e.year(), this.minMonth),
this.minDay
).toJD() +
1
);
},
daysInWeek: function () {
return 7;
},
dayOfWeek: function (b, c, d) {
var e = this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
);
return (Math.floor(this.toJD(e)) + 2) % this.daysInWeek();
},
extraInfo: function (b, c, d) {
return (
this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
),
{}
);
},
add: function (b, c, d) {
return (
this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
),
this._correctAdd(b, this._add(b, c, d), c, d)
);
},
_add: function (a, b, c) {
this._validateLevel++;
var d;
if ("d" === c || "w" === c) {
var e = a.toJD() + b * ("w" === c ? this.daysInWeek() : 1);
return (
(d = a.calendar().fromJD(e)),
this._validateLevel--,
[d.year(), d.month(), d.day()]
);
}
try {
var f = a.year() + ("y" === c ? b : 0),
g = a.monthOfYear() + ("m" === c ? b : 0);
d = a.day();
var h = function (a) {
for (; g < a.minMonth; ) f--, (g += a.monthsInYear(f));
for (var b = a.monthsInYear(f); g > b - 1 + a.minMonth; )
f++, (g -= b), (b = a.monthsInYear(f));
};
"y" === c
? (a.month() !== this.fromMonthOfYear(f, g) &&
(g = this.newDate(f, a.month(), this.minDay).monthOfYear()),
(g = Math.min(g, this.monthsInYear(f))),
(d = Math.min(
d,
this.daysInMonth(f, this.fromMonthOfYear(f, g))
)))
: "m" === c &&
(h(this),
(d = Math.min(
d,
this.daysInMonth(f, this.fromMonthOfYear(f, g))
)));
var i = [f, this.fromMonthOfYear(f, g), d];
return this._validateLevel--, i;
} catch (a) {
throw (this._validateLevel--, a);
}
},
_correctAdd: function (a, b, c, d) {
if (
!(
this.hasYearZero ||
("y" !== d && "m" !== d) ||
(0 !== b[0] && a.year() > 0 == b[0] > 0)
)
) {
var e = {
y: [1, 1, "y"],
m: [1, this.monthsInYear(-1), "m"],
w: [this.daysInWeek(), this.daysInYear(-1), "d"],
d: [1, this.daysInYear(-1), "d"],
}[d],
f = c < 0 ? -1 : 1;
b = this._add(a, c * e[0] + f * e[1], e[2]);
}
return a.date(b[0], b[1], b[2]);
},
set: function (b, c, d) {
this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
);
var e = "y" === d ? c : b.year(),
f = "m" === d ? c : b.month(),
g = "d" === d ? c : b.day();
return (
("y" !== d && "m" !== d) || (g = Math.min(g, this.daysInMonth(e, f))),
b.date(e, f, g)
);
},
isValid: function (a, b, c) {
this._validateLevel++;
var d = this.hasYearZero || 0 !== a;
if (d) {
var e = this.newDate(a, b, this.minDay);
d =
b >= this.minMonth &&
b - this.minMonth < this.monthsInYear(e) &&
c >= this.minDay &&
c - this.minDay < this.daysInMonth(e);
}
return this._validateLevel--, d;
},
toJSDate: function (b, c, d) {
var e = this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
);
return a.calendars.instance().fromJD(this.toJD(e)).toJSDate();
},
fromJSDate: function (b) {
return this.fromJD(a.calendars.instance().fromJSDate(b).toJD());
},
_validate: function (b, c, d, e) {
if (b.year) {
if (0 === this._validateLevel && this.name !== b.calendar().name)
throw (
a.calendars.local.differentCalendars ||
a.calendars.regionalOptions[""].differentCalendars
)
.replace(/\{0\}/, this.local.name)
.replace(/\{1\}/, b.calendar().local.name);
return b;
}
try {
if (1 === ++this._validateLevel && !this.isValid(b, c, d))
throw e.replace(/\{0\}/, this.local.name);
var f = this.newDate(b, c, d);
return this._validateLevel--, f;
} catch (a) {
throw (this._validateLevel--, a);
}
},
}),
(f.prototype = new e()),
a.extend(f.prototype, {
name: "Gregorian",
jdEpoch: 1721425.5,
daysPerMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
hasYearZero: !1,
minMonth: 1,
firstMonth: 1,
minDay: 1,
regionalOptions: {
"": {
name: "Gregorian",
epochs: ["BCE", "CE"],
monthNames: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
],
monthNamesShort: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
],
dayNames: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
],
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
digits: null,
dateFormat: "mm/dd/yyyy",
firstDay: 0,
isRTL: !1,
},
},
leapYear: function (b) {
var c = this._validate(
b,
this.minMonth,
this.minDay,
a.calendars.local.invalidYear ||
a.calendars.regionalOptions[""].invalidYear
);
return (
(b = c.year() + (c.year() < 0 ? 1 : 0)) % 4 == 0 &&
(b % 100 != 0 || b % 400 == 0)
);
},
weekOfYear: function (a, b, c) {
var d = this.newDate(a, b, c);
return (
d.add(4 - (d.dayOfWeek() || 7), "d"),
Math.floor((d.dayOfYear() - 1) / 7) + 1
);
},
daysInMonth: function (b, c) {
var d = this._validate(
b,
c,
this.minDay,
a.calendars.local.invalidMonth ||
a.calendars.regionalOptions[""].invalidMonth
);
return (
this.daysPerMonth[d.month() - 1] +
(2 === d.month() && this.leapYear(d.year()) ? 1 : 0)
);
},
weekDay: function (a, b, c) {
return (this.dayOfWeek(a, b, c) || 7) < 6;
},
toJD: function (b, c, d) {
var e = this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
);
(b = e.year()),
(c = e.month()),
(d = e.day()),
b < 0 && b++,
c < 3 && ((c += 12), b--);
var f = Math.floor(b / 100),
g = 2 - f + Math.floor(f / 4);
return (
Math.floor(365.25 * (b + 4716)) +
Math.floor(30.6001 * (c + 1)) +
d +
g -
1524.5
);
},
fromJD: function (a) {
var b = Math.floor(a + 0.5),
c = Math.floor((b - 1867216.25) / 36524.25);
c = b + 1 + c - Math.floor(c / 4);
var d = c + 1524,
e = Math.floor((d - 122.1) / 365.25),
f = Math.floor(365.25 * e),
g = Math.floor((d - f) / 30.6001),
h = d - f - Math.floor(30.6001 * g),
i = g - (g > 13.5 ? 13 : 1),
j = e - (i > 2.5 ? 4716 : 4715);
return j <= 0 && j--, this.newDate(j, i, h);
},
toJSDate: function (b, c, d) {
var e = this._validate(
b,
c,
d,
a.calendars.local.invalidDate ||
a.calendars.regionalOptions[""].invalidDate
),
f = new Date(e.year(), e.month() - 1, e.day());
return (
f.setHours(0),
f.setMinutes(0),
f.setSeconds(0),
f.setMilliseconds(0),
f.setHours(f.getHours() > 12 ? f.getHours() + 2 : 0),
f
);
},
fromJSDate: function (a) {
return this.newDate(a.getFullYear(), a.getMonth() + 1, a.getDate());
},
}),
(a.calendars = new b()),
(a.calendars.cdate = c),
(a.calendars.baseCalendar = e),
(a.calendars.calendars.gregorian = f);
})(jQuery);
//# sourceMappingURL=jquery.calendars.min.map