TP Underground Lounge 07/08
-


Hinweise


Antwort
 
LinkBack Themen-Optionen Thema durchsuchen Thema bewerten
Alt 13.05.2005, 22:48   #1
TP-Insider
 
Registriert seit: Jul 2003
Ort: München
Fexxx ist auf einem guten Weg

Nanu, Kalender rechnet "nur" den Mai falsch?


Mir ist gerade aufgefallen, dass mein Kalender plötzlich falsch geht. Switch ich aber einen Monat vor oder zurück, stimmen die Daten wieder? Steh auf dem Schlauch :/

http://newlevel.de/calendar2.php

PHP-Code:
<?php


    $calendar_language        
"ger";       //The extension of the calendar language file.
    
$table_border             0;           //The border of the table
    
$table_cellspacing        1;           //Cellspacing of the table
    
$table_cellpadding        2;           //Cellpadding of the table
    
$table_width              '180px';          //Table width in pixels or %'s
    
$table_height             '160px';    
   
    
$language_file  "calendar." $calendar_language;        //Language file into variable
    
$fd             fopen$language_file"r" );             //Open the language file
    
$fd             fread$fdfilesize$language_file ) ); //Read the opened file
    
$language_array explode"\n" $fd );                    //Put file info into array

    
$dayname   array_slice($language_array,0,7); //The names of the days

    
$monthname array_slice($language_array,7);   //The rest of the language file are the monthnames
    //
    /////////////////////////////////////////////


    /////////////////////////////////////////////
    //Use the date to build up the calendar. From the Query_string or the current date
    //    
    
if( isset( $_GET['date'] ) )
        list(
$month,$year) = explode("-",$_GET['date']);
    else
    {
        
$month date("m");
        
$year  date("Y");
    }
    
//
    /////////////////////////////////////////////

    
$date_string mktime(0,0,0,$month,1,$year); //The date string we need for some info... saves space ^_^

    
$day_start date("w",$date_string)-1;  //The number of the 1st day of the week

    /////////////////////////////////////////////
    //Filter the current $_GET['date'] from the QUERY_STRING
    //
    
$QUERY_STRING ereg_replace("&date=".$month."-".$year,"",$_SERVER['QUERY_STRING']);
    
//
    /////////////////////////////////////////////
    

    /////////////////////////////////////////////
    //Calculate the previous/next month/year
    //
    
if( $month 12 )
    {
        
$next_month $month+1;
        
$next_date $next_month."-".$year;
    }
    else
    {
        
$next_year $year+1;
        
$next_date "1-".$next_year;
        
$next_month 1;
    }
    if( 
$month )
    {
        
$previous_month $month-1;
        
$next_month    $month+1;
        
$previous_date $previous_month."-".$year;
    }
    else
    {
        
$previous_year $year-1;
        
$previous_date "12-".$previous_year;
        
$previous_month 12;
    }
    
//
    /////////////////////////////////////////////

    // darussol: DEFINITION OF THETRANSLATED MONTH+YEAR TO BE USED IN THE TABLE AND INFO-TITLES (18 May 2004)
    // e-man   : USING THE VALUES OF THE PREVIOUS AND NEXT MONTH FOR THE TITLE DAY (19 May 2004);
    
    
$table_caption      $monthname[date("n",$date_string)-1] . " " $year// current
    

    
    
    /////////////////////////////////////////////
    //Print the calendar table header
    //
    
echo "
        
        <table border=\"" 
$table_border "\" cellpadding=\"" $table_cellpadding "\" cellspacing=\"" $table_cellspacing "\" style=\"height:" $table_height "\" width=\"" $table_width "\">
            <tr>
                <td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" 
$_SERVER['PHP_SELF'] . "?" $QUERY_STRING "&amp;date=" .
                
$previous_date "\" title=\"" $table_caption_prev "\">&laquo;</a></td>
                <td align=\"center\" class=\"cal_head\" colspan=\"5\">" 
$table_caption "</td>
                <td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" 
$_SERVER['PHP_SELF'] . "?" $QUERY_STRING "&amp;date=" .
                
$next_date "\" title=\"" $table_caption_foll "\">&raquo;</a></td>
            </tr>
            <tr>
                <td class=\"cal_days\">"
.$dayname[0]."</td>
                <td class=\"cal_days\">"
.$dayname[1]."</td>                
                <td class=\"cal_days\">"
.$dayname[2]."</td>
                <td class=\"cal_days\">"
.$dayname[3]."</td>
                <td class=\"cal_days\">"
.$dayname[4]."</td>
                <td class=\"cal_days\">"
.$dayname[5]."</td>
                <td class=\"cal_days\">"
.$dayname[6]."</td>
                
            </tr><tr>
            "
;
    
//
    /////////////////////////////////////////////
    
    /////////////////////////////////////////////
    //The empty columns before the 1st day of the week
    //
    
for( $i $i $day_start$i++ )
    {
        echo 
"<td class=\"cal_content\">&nbsp;</td>";
    }
    
//
    /////////////////////////////////////////////
    
    
$current_position $day_start//The current (column) position of the current day from the loop
    
    
$total_days_in_month date("t",$date_string); //The total days in the month for the end of the loop

    

    /////////////////////////////////////////////
    //Loop all the days from the month
    //
    
for( $i 1$i <= $total_days_in_month $i++)
    {
        
$class "cal_content";
        
        if( 
$i == date("j") && $month == date("n") && $year == date("Y") )
            
$class "cal_today";
        
        
$current_position++;
    
/* for the event filter */
    /* e-man : added 07 June 04 */
    
$date_stamp $year."-".$month."-".sprintf"%02d",$i);
        echo 
"<td align=\"center\" class=\"" $class "\">" $link_start $i $link_end "</td>";
        if(
$day_start==-&& $current_position == && $i<=7){
        echo 
"</tr><tr>\n";
            
$current_position 0;
            }
        if( 
$current_position == 7)
        {
            echo 
"</tr><tr>\n";
            
$current_position 0;
        }
    }
    
//
    /////////////////////////////////////////////
    
    
$end_day 7-$current_position//There are
    
    /////////////////////////////////////////////
    //Fill the last columns
    //    
    
for( $i $i $end_day $i++ )
        echo 
"<td class=\"cal_content\"></td>\n";
    
//
    /////////////////////////////////////////////
    
    
echo "</tr></table>";  // Close the table
    

    
?>
__________________
Spitzen Hoster: All-Inkl
Fexxx ist offline   Mit Zitat antworten


Alt 13.05.2005, 22:56   #2
TP-Special Mod
 
Benutzerbild von steffenk
 
Registriert seit: Feb 2005
Ort: Haan / NRW
steffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine User
was geht denn falsch ?
lass Dir doch mal $month und $year ausgeben
__________________

Typo3 · MySQLDumper · dislabs
·
manche Mühlen mahlen schneller ...
"Ich habe Rücken"
Horst Schlämmer
steffenk ist gerade online   Mit Zitat antworten
Alt 14.05.2005, 09:15   #3
TP-Insider
 
Registriert seit: Jul 2003
Ort: München
Fexxx ist auf einem guten Weg
Der Monat Mai fängt am Montag den 1. an, der 1. war aber ein Sonntag. Komisch ist, dass die Monate davor und danach stimmen, das macht mit Kopfschmerzen: :/
__________________
Spitzen Hoster: All-Inkl
Fexxx ist offline   Mit Zitat antworten
Alt 14.05.2005, 11:22   #4
TP-Junior
 
Registriert seit: Oct 2003
Ort: Geburtsort: Köln, Wohnort: Berlin
codethief ist auf einem guten Weg
Hier: http://newlevel.de/calendar2.php?&date=12-2005 - http://newlevel.de/calendar2.php?&date=1-2006

und

hier: http://newlevel.de/calendar2.php?&date=9-2006 - http://newlevel.de/calendar2.php?&date=10-2006

haut es auch nicht hin...

Das Problem scheint auch immer nur dann aufzutreten, wenn der erste Monat (erste URL) davor mit einem Samstag endete. Der darauffolgende fängt dann statt mit einem Sontag mit einem Montag an. Trotz dieser Verschiebung um einen Tag geht bei dem nächsten Monat wieder alles richtig.


codethief.
__________________
PHP unser,
dein Quelltext speicher,
deine Syntax erleuchte,
wie in Windows so auf Linux.
Dein Output-Buffering starte,
dein Template lade,
deine Session starte,
wie in v4 so in v5.
In Ewigkeit - AMEN
codethief ist offline   Mit Zitat antworten
Alt 14.05.2005, 13:06   #5
TP-Special Mod
 
Benutzerbild von steffenk
 
Registriert seit: Feb 2005
Ort: Haan / NRW
steffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine Usersteffenk lebt für das TP und seine User
Dank codethief wars leicht aufzuspüren.

Folgende Modifikation:

$day_start = date("w",$date_string)-1; //The number of the 1st day of the week
if($day_start<0) $day_start=6;

Bei Sonntag(0) wurde einfach 1 abgezogen und 0-1 = -1 statt 6
__________________

Typo3 · MySQLDumper · dislabs
·
manche Mühlen mahlen schneller ...
"Ich habe Rücken"
Horst Schlämmer
steffenk ist gerade online   Mit Zitat antworten
Alt 14.05.2005, 20:35   #6
TP-Insider
 
Registriert seit: Jul 2003
Ort: München
Fexxx ist auf einem guten Weg
Super, Vielen Dank !
__________________
Spitzen Hoster: All-Inkl
Fexxx ist offline   Mit Zitat antworten
Antwort

  Aktuelles Thema
  TP Hilfe Forum > Web-Editoren & Coding > Traum-Dynamik
Nanu, Kalender rechnet "nur" den Mai falsch? Nanu, Kalender rechnet "nur" den Mai falsch?
« [PHP] Vorschau eines komplexen Formulars | Bockt meine Datenbank? »

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:27 Uhr.

Powered by: vBulletin Version 3.7 (Deutsch)
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. / Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Traum-Projekt.com | Suchen | Archiv | Impressum | Kontakt | | | Nach oben |



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67