wfm-mobile-core
Version:
WFM Mobile Core
75 lines (74 loc) • 2.59 kB
JavaScript
;
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __read = (this && this.__read) || function (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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntlFormatters = exports.supportsTouch = exports.dateISOFormat = void 0;
var locales = ['ru-RU', 'en-US'];
var dateISOFormat = function (date) {
var d = new Date(date);
var timeDifferUTC = -1 * d.getTimezoneOffset() * 60000;
var millisecondsDate = d.getTime();
var formattedDate = new Date(millisecondsDate + timeDifferUTC).toISOString();
return formattedDate.slice(0, 10);
};
exports.dateISOFormat = dateISOFormat;
var supportsTouch = 'ontouchstart' in window || navigator.maxTouchPoints;
exports.supportsTouch = supportsTouch;
var IntlFormatters = /** @class */ (function () {
function IntlFormatters(locale) {
var _this = this;
this.initFormatter = function (options) { return new Intl.DateTimeFormat(_this.locales, options); };
this.locales = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], [locale]), __read(locales)))));
this.date = this.initFormatter({
day: '2-digit',
month: '2-digit',
year: 'numeric',
});
this.time = this.initFormatter({
hour: '2-digit',
minute: '2-digit',
});
this.weekday = this.initFormatter({
weekday: 'short',
});
this.monthYear = this.initFormatter({
month: 'long',
year: 'numeric',
});
this.dayWeekdayMonth = this.initFormatter({
day: 'numeric',
month: 'long',
weekday: 'long',
});
this.dayMonth = this.initFormatter({
day: 'numeric',
month: 'long',
});
this.dayMonthYear = this.initFormatter({
day: 'numeric',
month: 'long',
year: 'numeric',
});
}
return IntlFormatters;
}());
exports.IntlFormatters = IntlFormatters;