Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Kalender: falsche Anzeige der Kalenderwoche

Aloittaja Dirk67, joulukuu 04, 2006, 02:07:01 AP

« edellinen - seuraava »

Dirk67

Hi,

wenn man in    Profil -> Design & Layout -> Tag des Wochenanfangs
auf Montag stellt, dann wird im Kalender die Kalenderwoche (KW) falsch angezeigt  :o

Ich möchte es so haben wie auf einem "normalen deutschen Kalender" ;) d.h.
18.12. - 24.12.06 => KW 51
25.12. - 31.12.06 => KW 52

es wird aber (falsch) angezeigt (auch in diesem Forum):
18.12. - 24.12.06 => KW 52
25.12. - 31.12.06 => KW 53
(bei Tag des Wochenanfangs = Montag)

kann man das irgendwie beheben ?
Board-Info Server-Info
using: SMF 1.1.3 PHP Version: 4.4.1
charset = UTF-8 MySQL Version: 4.1.22-debug-log
Mods: - User Email System Server Version: Apache/1.3 (Unix) mod_ssl
        - AVV by HarzeM GD Version: bundled (2.0.28 compatible)


web is what we make it .


Dirk67

Board-Info Server-Info
using: SMF 1.1.3 PHP Version: 4.4.1
charset = UTF-8 MySQL Version: 4.1.22-debug-log
Mods: - User Email System Server Version: Apache/1.3 (Unix) mod_ssl
        - AVV by HarzeM GD Version: bundled (2.0.28 compatible)


web is what we make it .

Dirk67

#3
OK, ich habe eine Lösung gefunden:  ;)

SMF 1.1. final: korrekte Anzeige der Kalenderwochen nach "ISO 8601:1988" (Deutschland und Europa)
(Achtung:nach Durchführung dieser Modifikation ist der "Beginn der Woche" fest auf Montag gestellt,
egal was der User in seinem Profil einstellt.)


Die folgenden 4 Modifikationen müssen alle in der Datei  "...\Sources\Calendar.php" durchgeführt werden:
(Wichtig: vorher ein Backup der Originaldatei machen)




Modifikation 1:

Original:


// Get information about the first day of this month.
$firstDayOfMonth = array(
'dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year'])),
'weekNum' => (int) strftime('%U', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year']))
);


Modifiziert:
(das "strftime('%U',..." wird gegen "strftime('%V',..." ersetzt)

// Get information about the first day of this month.
$firstDayOfMonth = array(
'dayOfWeek' => (int) strftime('%w', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year'])),
'weekNum' => (int) strftime('%V', mktime(0, 0, 0, $curPage['month'], 1, $curPage['year']))
);





Modifikation 2:

Original:


// Calendar start day- default Sunday.
$nStartDay = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;


Modifiziert:
(Wochenanfang fest auf Montag setzen => Voraussetzung für "ISO 8601:1988")

// Calendar start day immer Montag:
$nStartDay = 1;





Modifikation 3:

Original:


// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['weeks'][$nRow] = array(
'days' => array(),
'number' => $firstDayOfMonth['weekNum'] + $nRow + $nWeekAdjust
);


Modifiziert:
(das "+ $nWeekAdjust" fällt weg)

// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
$context['weeks'][$nRow] = array(
'days' => array(),
'number' => $firstDayOfMonth['weekNum'] + $nRow
);





Modifikation 4:

Original:


// Handle the dreaded "week 53", it can happen, but only once in a blue moon ;)
if ($context['weeks'][$nRow]['number'] == 53 && $nShift != 4)
$context['weeks'][$nRow]['number'] = 1;$context['weeks'][$nRow]['number'] = 1;


Erzetzt(!) durch:
(Achtung: die obigen Zeilen werden komplett ersetzt durch die folgenden)

// für Januare, welche mit KW 52 oder KW 53 anfangen:
if ($curPage['month'] == 1)
{
if (($firstDayOfMonth['weekNum'] == 52) || ($firstDayOfMonth['weekNum'] == 53))
{
if ($nRow > 0)
$context['weeks'][$nRow]['number'] = $nRow;
}
}
// für Dezember, welche mit KW 53 bzw. KW 1 aufhören:
if ($curPage['month'] == 12)
{
if ($context['weeks'][$nRow]['number'] == 53)
{
// auf die Wochennummer der ersten Woche des Folgejahres setzen:
$context['weeks'][$nRow]['number'] = (int) strftime('%V', mktime(0, 0, 0, 1, 1, ($curPage['year']+1)));
}
}






Ich habe zwar ausgiebig getestet,
für Rückmeldungen Eurer eigenen Erfahrungen damit wäre ich aber sehr dankbar.


...
Board-Info Server-Info
using: SMF 1.1.3 PHP Version: 4.4.1
charset = UTF-8 MySQL Version: 4.1.22-debug-log
Mods: - User Email System Server Version: Apache/1.3 (Unix) mod_ssl
        - AVV by HarzeM GD Version: bundled (2.0.28 compatible)


web is what we make it .

Dirk67

Board-Info Server-Info
using: SMF 1.1.3 PHP Version: 4.4.1
charset = UTF-8 MySQL Version: 4.1.22-debug-log
Mods: - User Email System Server Version: Apache/1.3 (Unix) mod_ssl
        - AVV by HarzeM GD Version: bundled (2.0.28 compatible)


web is what we make it .

Advertisement: