Angular-calendar: How to shorten a day in calendar header?

Created on 7 Dec 2016  路  3Comments  路  Source: mattlewis92/angular-calendar

I am using angular-calendar for mobile app and calendar header day is appearing in Full text with ellipse css property.
But i want it to be like Sun,Mon,Tues etc.

Most helpful comment

Sure thing:

import {CalendarNativeDateFormatter, DateFormatterParams, CalendarModule} from 'angular2-calendar';

class CustomDateFormatter extends CalendarNativeDateFormatter {

  public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
    return new Intl.DateTimeFormat(locale, {weekday: 'short'}).format(date);
  }

}

@NgModule({
  import: [CalendarModule],
  providers: [
    CalendarEventTitleProvider, 
     {provide: CalendarDateFormatter, useClass: CustomDateFormatter}
  ]
})
class ModuleThatUsesTheCalendar{}

All 3 comments

See this answer: https://github.com/mattlewis92/angular-calendar/issues/78#issuecomment-256573939

But override the monthViewColumnHeader method. Hope that helps! 馃槂

I'm not able to do . Can u provide a code ?

Sure thing:

import {CalendarNativeDateFormatter, DateFormatterParams, CalendarModule} from 'angular2-calendar';

class CustomDateFormatter extends CalendarNativeDateFormatter {

  public monthViewColumnHeader({date, locale}: DateFormatterParams): string {
    return new Intl.DateTimeFormat(locale, {weekday: 'short'}).format(date);
  }

}

@NgModule({
  import: [CalendarModule],
  providers: [
    CalendarEventTitleProvider, 
     {provide: CalendarDateFormatter, useClass: CustomDateFormatter}
  ]
})
class ModuleThatUsesTheCalendar{}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

no-more picture no-more  路  3Comments

oldschoolbg picture oldschoolbg  路  4Comments

teodoramalec picture teodoramalec  路  4Comments

AstRonin picture AstRonin  路  4Comments

sylvain-fr picture sylvain-fr  路  3Comments