src/providers/calendarMomentDateFormatter.provider.ts
This will use moment to do all date formatting. To use this class:
import { CalendarDateFormatter, CalendarMomentDateFormatter, MOMENT } from 'angular-calendar';
import * as moment from 'moment';
// in your component
provide: [{
provide: MOMENT, useValue: moment
}, {
provide: CalendarDateFormatter, useClass: CalendarMomentDateFormatter
}]
Public monthViewColumnHeader |
monthViewColumnHeader(undefined: DateFormatterParams)
|
The month view header week day labels
Returns:
string
|
Public monthViewDayNumber |
monthViewDayNumber(undefined: DateFormatterParams)
|
The month view cell day number
Returns:
string
|
Public monthViewTitle |
monthViewTitle(undefined: DateFormatterParams)
|
The month view title
Returns:
string
|
Public weekViewColumnHeader |
weekViewColumnHeader(undefined: DateFormatterParams)
|
The week view header week day labels
Returns:
string
|
Public weekViewColumnSubHeader |
weekViewColumnSubHeader(undefined: DateFormatterParams)
|
The week view sub header day and month labels
Returns:
string
|
Public weekViewTitle |
weekViewTitle(undefined: DateFormatterParams)
|
The week view title
Returns:
string
|
Public dayViewHour |
dayViewHour(undefined: DateFormatterParams)
|
The time formatting down the left hand side of the day view
Returns:
string
|
Public dayViewTitle |
dayViewTitle(undefined: DateFormatterParams)
|
The day view title
Returns:
string
|
import { OpaqueToken, Inject } from '@angular/core';
import { CalendarDateFormatterInterface, DateFormatterParams } from './../interfaces/calendarDateFormatter.interface';
export const MOMENT: OpaqueToken = new OpaqueToken('Moment');
/**
* This will use <a href="http://momentjs.com/" target="_blank">moment</a> to do all date formatting. To use this class:
*
* ```
* import { CalendarDateFormatter, CalendarMomentDateFormatter, MOMENT } from 'angular-calendar';
* import * as moment from 'moment';
*
* // in your component
* provide: [{
* provide: MOMENT, useValue: moment
* }, {
* provide: CalendarDateFormatter, useClass: CalendarMomentDateFormatter
* }]
*
* ```
*/
export class CalendarMomentDateFormatter implements CalendarDateFormatterInterface {
/**
* @hidden
*/
constructor(@Inject(MOMENT) private moment: any) {}
/**
* The month view header week day labels
*/
public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('dddd');
}
/**
* The month view cell day number
*/
public monthViewDayNumber({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('D');
}
/**
* The month view title
*/
public monthViewTitle({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('MMMM YYYY');
}
/**
* The week view header week day labels
*/
public weekViewColumnHeader({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('dddd');
}
/**
* The week view sub header day and month labels
*/
public weekViewColumnSubHeader({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('D MMM');
}
/**
* The week view title
*/
public weekViewTitle({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('[Week] W [of] YYYY');
}
/**
* The time formatting down the left hand side of the day view
*/
public dayViewHour({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('ha');
}
/**
* The day view title
*/
public dayViewTitle({date, locale}: DateFormatterParams): string {
return this.moment(date).locale(locale).format('dddd, D MMMM, YYYY');
}
}