Format date in timesheet mode (Angular 5)
Asked by Guenther8 years ago.
I'm currently working on a timesheet component, and I want to display the dayname in front of the date. However, the only property I found is headerdateproperty. If I set a valid date-pattern nothing changes, it displays always according to my locale (de-at).
Answer posted by Dan Letecky [DayPilot]8 years ago.
By default, the timesheet uses the short date format specified using the current locale for the day headers.
You can customize the text using onBeforeRowHeader render event handler:
config: any = {
onBeforeRowHeaderRender: args => {
args.row.html = args.row.start.toString("dddd M/d/yyyy");
},
// ...
}
See also:
https://code.daypilot.org/26933/angular-6-timesheet-quick-start-project
Comment posted by Guenther8 years ago.
Hi Dan,
thank you. Now the next problem:
locale: 'de-at',
...
args.row.html = args.row.start.toString('ddd dd.MM.yyyy');
=> but in that case I get the day names in English, not in German (as expected by the locale)
Comment posted by Dan Letecky [DayPilot]8 years ago.
Hi Günther,
You can specify the locale as the second parameter like this:
args.row.html = args.row.start.toString('ddd dd.MM.yyyy', 'de-at');
or
args.row.html = args.row.start.toString('ddd dd.MM.yyyy', this.config.locale);
Let me know if it didn't help.
Comment posted by Guenther8 years ago.
Great, thank you for you help.
This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.