WordPress.org

Ready to get started?Download WordPress

Forums

wp1.0 week in calendar always starts on Sunday (8 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    setting week start on Monday in base settings cause none effect. Calendar always start the week on Sunday.

  2. Anonymous
    Unregistered
    Posted 10 years ago #

    You have to modify wp-includes/template-functions.
    Line 435: Replace:
    $pad = intval(date('w', $unixmonth)); by
    $pad = intval(date('w', $unixmonth)-1);
    and
    Line 455: Replace:
    if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) by
    if (0 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
    I hope this help you.

  3. ByteWarrior
    Member
    Posted 10 years ago #

    Well, I tried this bugfix. But my calendar still starts with a Sunday. The weekday headers are now totally wrong. They should start with 'M', not with 'S'. Where can I fix this?

  4. Erkki
    Member
    Posted 10 years ago #

    HELP! says the newbie fighting with the get_calendar function in order to display Monday as the first day of the calendar and not Sunday!
    Sometimes steps are obvious but if you miss one, damn!
    I took me quite a while to figure it out (think, Forrest, think) but here's a "little bit more detailed way" to succeed in customizing the calendar and it's display.
    This solution works pretty well with a small issue though (don't panic! It's not that ugly and there's a fix):
    1- You have to modify and translate in wp-config-extra.php the $weekday[0]='Sunday' to 'Monday' or 'Maanantai' in Finnish for example and keep the list logical unless you want to have a funky calendar! (that's probably where most of the newbies got stucked with non working mod then)
    2- Modify the code in template-function.php. (you can also look for // See how much we should pad in the beginning, the mods to make are just below that comment.)
    around line 435 replace:
    $pad = intval(date('w', $unixmonth));
    by
    $pad = intval(date('w', $unixmonth)-1);
    and
    around line 455, replace:
    if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))) by
    if (0 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
    3- Sit back and enjoy your calendar starting with Monday :)
    The "small" issue is (for me at least) that in the first row of February day 1 stands under Tuesday but should be under Sunday. I've tried with other months (30 & 31 days) and it just looks fine with rows & cells.
    Pity for February?
    Here you can fix it (thanks smo!):
    http://wordpress.org/support/3/2629
    Just follow the steps and you're done!
    Thanks to WP community for making this possible:)

  5. Sebbi
    Member
    Posted 9 years ago #

    Erku,
    wouldnt that result in negative paddings if date returns 0 and start_of_week is 1?

  6. ErKu
    Member
    Posted 9 years ago #

    Not sure. Works perfectly for me so far.

  7. Anonymous
    Unregistered
    Posted 9 years ago #

    For WP 1.2.1:
    It's wp-includes/template-functions-general.php
    line 457:
    $pad = intval(date('w', $unixmonth-1));
    line 478:
    if (0 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
    And wp-includes/locale.php:
    $weekday[0] = __('Monday');
    $weekday[1] = __('Tuesday');
    $weekday[2] = __('Wednesday');
    $weekday[3] = __('Thursday');
    $weekday[4] = __('Friday');
    $weekday[5] = __('Saturday');
    $weekday[6] = __('Sunday');
    That's it, now calendar weeks start with Monday, as is proper on this side of the pond.

  8. philaweb
    Member
    Posted 9 years ago #

    Fixes posted by 'Anonymous' works great!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags