UNPKG

angular-calendar

Version:

A calendar component that can display events on a month, week or day view

78 lines 3.05 kB
import getISOWeek from 'date-fns/get_iso_week'; /** * This will use <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Intl" target="_blank">Intl</a> API to do all date formatting. It is the default date formatter used by the calendar. * * You will need to include a <a href="https://github.com/andyearnshaw/Intl.js/">polyfill</a> for older browsers. */ export var CalendarNativeDateFormatter = (function () { function CalendarNativeDateFormatter() { } /** * The month view header week day labels */ CalendarNativeDateFormatter.prototype.monthViewColumnHeader = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(date); }; /** * The month view cell day number */ CalendarNativeDateFormatter.prototype.monthViewDayNumber = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { day: 'numeric' }).format(date); }; /** * The month view title */ CalendarNativeDateFormatter.prototype.monthViewTitle = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'long' }).format(date); }; /** * The week view header week day labels */ CalendarNativeDateFormatter.prototype.weekViewColumnHeader = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(date); }; /** * The week view sub header day and month labels */ CalendarNativeDateFormatter.prototype.weekViewColumnSubHeader = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'short' }).format(date); }; /** * The week view title */ CalendarNativeDateFormatter.prototype.weekViewTitle = function (_a) { var date = _a.date, locale = _a.locale; var year = new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(date); var weekNumber = getISOWeek(date); return "Week " + weekNumber + " of " + year; }; /** * The time formatting down the left hand side of the day view */ CalendarNativeDateFormatter.prototype.dayViewHour = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { hour: 'numeric' }).format(date); }; /** * The day view title */ CalendarNativeDateFormatter.prototype.dayViewTitle = function (_a) { var date = _a.date, locale = _a.locale; return new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'long', year: 'numeric', weekday: 'long' }).format(date); }; return CalendarNativeDateFormatter; }()); //# sourceMappingURL=calendarNativeDateFormatter.provider.js.map