Calendar Class Bug Fix, version 2.6 available!

A couple of calendar class users noticed an issue with the feature for controlling the day that weeks start on. The class has been updated with a fix. The fix involves replacing the use of PHP’s data(“w”) with date(“N”). date(“N”) uses the ISO-8601 numeric representation of the day of the week. Days of the week are represented as 1 = Monday thru 7 = Sunday. This is different from the old behavior which was 0 = Sunday thru 6 = Saturday.

Since the new behavior could cause unexpected display if the user was unaware of the change, the old property for controlling this feature has been disabled. Use the new property $week_start to control this feature now! Using the disabled week_start_on property will cause an error message to be displayed!

The new version (v2.6) is available for download on the calendar.class.php download page

7 Comments

  1. battisti

    # June 3, 2008 - 8:35 pm

    Hi i foud your class and it’s like very god, nice job!

    I have one sugestion: you use the function gmstrftime to get the name of days month if the configuration of the host was wrong the calendar will display wrong to, for example my host is in USA but my user not.

  2. pharri

    # June 5, 2008 - 4:23 am

    Hi Jim ! Thanks for your calendar class. But i can’t get french localized output. Setlocale(LC_ALL, ‘fr_FR’) doesn’t work. I am using wamp 1.6.4 on my PC (xp pro). How to get fr localization ?

  3. pharri

    # June 5, 2008 - 4:35 am

    Hi, Jim ! it’s me again. My problem is resolved by using setlocale(LC_ALL, ‘french’) instead of ‘fr_FR’. Thank you for your job.

  4. fresher

    # June 13, 2008 - 10:51 am

    Hi. nice calendar and very useful in my web. BUT..
    how can i make that different days will be linked to different pages…? thanks!

  5. Jim Mayes

    # June 13, 2008 - 11:02 am

    Well, if you mean link june 13, 2008 to this_page.html and link June 14, 2008 to that_page.html… you can’t at this time. Might add that in the future, maybe not, not sure.

    The way the class is designed to work, the days link to a second script. Like day.php for example. Then in that script you read the date passed from $_GET and use that date to do what you need to do with PHP, ie pull a corresponding day’s record from a DB or something.

  6. fresher

    # June 14, 2008 - 9:48 am

    yes you are right jim what i mean… now the dates are link to “?date=2008-06-18″ (example). maybe somebody know how to link these dates to pages in php fusion…because here the links work similar..example if you want to read more in news section you click a link with tag news.php?readmore=14 … maybe in this calendar can do something similar?

  7. Jim Mayes

    # June 14, 2008 - 8:05 pm

    you might be able to do what you need with the formatted_link_to property, but again there really isn’t a way to make the class link different dates to completely different pages as it is now. So as long as your base page is the same and you just need to pass the variables, it might work out for you.

    formatted_link_to let’s you pass in a formatting string to be used for the links, so you could do something like this:

    $calendar->formatted_link_to = '/news.php?date=%Y-%m-%d';
    

    or even something like:

    $calendar->formatted_link_to = '/news.php?year=%Y&month=%m&day=%d';
    

    The string you provide here basically gets feed to strftime so you can use any of the formatting specifiers that strftime uses. The lines where this happens are 190 and 200 in the class. They look like this:

    $output .= "formatted_link_to, strtotime($day_date)) . "\">";
    

    so as you can see, you have a lot of possibilities as far as what you put into it. The only thing is, all of the linked days are gonna use that same format! Hope that helps.

Leave a Reply