]> git.mjollnir.org Git - moodle.git/commitdiff
Fix to display correctly formatted dates in some cases where they were not
authordefacer <defacer>
Fri, 30 Apr 2004 08:59:04 +0000 (08:59 +0000)
committerdefacer <defacer>
Fri, 30 Apr 2004 08:59:04 +0000 (08:59 +0000)
being localized as they should. Also, small cosmetic addition of a space between
words in the date representation (I had missed it).

calendar/lib.php
calendar/view.php

index 407ca1624748b05737d62545ed90683fe3ec590f..37ae0254e7d9fa2adaab6f32edfb1409e33d5667 100644 (file)
@@ -540,7 +540,7 @@ function calendar_top_controls($type, $data) {
             $nextname = calendar_month_name($nextdate['month']);
             $content .= "<table style='width: 100%;'><tr>\n";
             $content .= '<td style="text-align: left; width: 30%;"><a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $prevmonth, $prevyear).'">&lt;&lt; '.$prevname.' '.$prevyear."</a></td>\n";
-            $content .= '<td style="text-align: center"><strong>'.$monthname.' '.$data['y']."</strong></td>\n";
+            $content .= '<td style="text-align: center"><strong>'.strftime(get_string('strftimemonthyear'), $time)."</strong></td>\n";
             $content .= '<td style="text-align: right; width: 30%;"><a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $nextmonth, $nextyear).'">'.$nextname.' '.$nextyear." &gt;&gt;</a></td>\n";
             $content .= "</tr></table>\n";
         break;
@@ -553,7 +553,17 @@ function calendar_top_controls($type, $data) {
             $nextname = calendar_wday_name($nextdate['weekday']);
             $content .= "<table style='width: 100%;'><tr>\n";
             $content .= '<td style="text-align: left; width: 20%;"><a href="'.calendar_get_link_href('view.php?view=day&amp;', $prevdate['mday'], $prevdate['mon'], $prevdate['year']).'">&lt;&lt; '.$prevname."</a></td>\n";
-            $content .= '<td style="text-align: center"><strong>'.$dayname.', '.$data['d'].' <a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">'.$monthname.' '.$data['y']."</a></strong></td>\n";
+
+            // Get the format string
+            $text = get_string('strftimedaydate');
+            // Regexp hackery to make a link out of the month/year part
+            $text = ereg_replace('(%B.+%Y|%Y.+%B|%Y.+%m[^ ]+)', '<a href="'.calendar_get_link_href('view.php?view=month&amp;', 1, $data['m'], $data['y']).'">\\1</a>', $text);
+            // Replace with actual values and lose any day leading zero
+            $text = strftime($text, $time);
+            $text = str_replace(' 0', ' ', $text);
+            // Print the actual thing
+            $content .= '<td style="text-align: center"><strong>'.$text."</strong></td>\n";
+
             $content .= '<td style="text-align: right; width: 20%;"><a href="'.calendar_get_link_href('view.php?view=day&amp;', $nextdate['mday'], $nextdate['mon'], $nextdate['year']).'">'.$nextname." &gt;&gt;</a></td>\n";
             $content .= "</tr></table>\n";
         break;
@@ -649,7 +659,7 @@ function calendar_day_representation($tstamp, $now = false, $usecommonwords = tr
     }
 
     // To have it in one place, if a change is needed
-    $formal = get_string($days[userdate($tstamp, '%w')], 'calendar') . userdate($tstamp, $shortformat);
+    $formal = get_string($days[userdate($tstamp, '%w')], 'calendar').' '.userdate($tstamp, $shortformat);
 
     // Reverse TZ compensation: make GMT stamps correspond to user's TZ
     $tzfix = calendar_get_tz_offset();
index f33050dd89e6e0d103ff8ca351469f197b0728a5..cbf58eb06f80afbb2ad293c27cf7b68231675df5 100644 (file)
         $mon = intval($now['mon']);
         $yr = intval($now['year']);
     }
+    $time = mktime(0, 0, 0, $mon, $day, $yr);
 
     switch($_GET['view']) {
         case 'day':
-            $nav .= ' -> '.$day.' '.calendar_month_name($mon).' '.$yr;
+            $text = strftime(get_string('strftimedate'), $time);
+            if($text[0] == '0') {
+                $text = substr($text, 1);
+            }
+            $nav .= ' -> '.$text;
             $pagetitle = get_string('dayview', 'calendar');
         break;
         case 'month':
-            $nav .= ' -> '.calendar_month_name($mon).' '.$yr;
+            $nav .= ' -> '.strftime(get_string('strftimemonthyear'), $time);
             $pagetitle = get_string('detailedmonthview', 'calendar');
         break;
         case 'upcoming':