sugi / jquery-gcal-flow

jQuery Google Calendar Flow plugin
62 stars 28 forks source link

Is there a way to show the month in a 3 letter abbreviation? #2

Closed rohwer3 closed 11 years ago

rohwer3 commented 11 years ago

Love the project and it works wonderful! I was wondering if there was a way of making the month from a two digit number to a 3 digit abbreviation?

For example 2013-01-17 would display as 2013-Jan-17?

sugi commented 11 years ago

Hello,

You can configure date format with date_formatter and daterange_formatter options. But it is a little bit complex. You need to write formatter functions.

Here is a sample function to set as date_formatter:

function(d, allday_p) {
    var pad_zero = function (n) { if (n < 10) n = "0" + n; return(n); };
    var month_names = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
    var ret = d.getFullYear() + "-" + month_names[d.getMonth()] + "-" + pad_zero(d.getDate());
    if (!allday_p)
         datestr += " " + pad_zero(d.getHours()) + ":" + pad_zero(d.getMinutes());
    return datestr;
}

Don't forget to tune daterange_formatter also if you have any range events.

matthewpizza commented 11 years ago

I have added days of the week as well.

function (d, allday_p) {
    var dayoftheweek = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
    var monthname = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];
    return dayoftheweek[d.getDay()] + ", " + monthname[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear();
}