Chris
Chris

Reputation: 845

FullCalendar (agendaWeek view): titleFormat for weeks overlapping a month

I have a question concerning the FullCalendar from Adam Shaw:

My titleFormat for the agendaWeek-View currently is formatted like this:

"20 — 26 October 2013"

When I go to the next week, it is an overlapping one as part of the week is in October and the rest is in November, resulting in:

"27 — 2 November 2013" 

This is not what I need. The correct way of displaying this week title would be something like this:

"27 October — 2 November 2013"

Is there a way of accomplishing that?

This is my current titleFormat in fullcalendar:

titleFormat: {
   month: 'MMMM yyyy',
   week: "d[ yyyy]{ '—' d MMMM yyyy}",
   day: 'dddd, d.MM.yyyy'
}

EDIT:

I hadn´t thought of something pretty obvious. Changing the titleFormat option to

titleFormat: {
   month: 'MMMM yyyy',
   week: "d MMMM[ yyyy]{ '—' d MMMM yyyy}",
   day: 'dddd, d.MM.yyyy'
}

results in

"27 Oktober — 2 November 2013"

which is correct. On the other hand I don´t want the month for the start date to be displayed in the non-overlapping weeks - is there a solution for that?

Upvotes: 0

Views: 6859

Answers (2)

nomatteus
nomatteus

Reputation: 502

To optionally display the month, only if it's different, you should be able to put it in square brackets, like so: [MMMM]

So your full title format would be:

 titleFormat: {
    month: 'MMMM yyyy',
    week: "d MMMM[ yyyy]{ '—' d [MMMM ]yyyy}",
   day: 'dddd, d.MM.yyyy'
}

Upvotes: 1

MaxD
MaxD

Reputation: 574

Try:

week:  "d [MMM]{ '–' d MMM}",

(add [yyyy] or yyyy if you want)

Upvotes: 1

Related Questions