]> git.mjollnir.org Git - s9y.git/commitdiff
Omid, please try to keep code duplication to a minimum.
authorgarvinhicking <garvinhicking>
Mon, 4 Jul 2005 12:14:18 +0000 (12:14 +0000)
committergarvinhicking <garvinhicking>
Mon, 4 Jul 2005 12:14:18 +0000 (12:14 +0000)
See seperate mail on the mailinglist.

index.php

index c89d971b40835e687a55af96af0aee34af49fdbe..a85199bdc45f204d26b6a8e3fc2a5a5ce68121b8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -119,57 +119,51 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     switch($serendipity['calendar']) {
         case 'gregorian':
         default:
-            if ($week) {
-                $tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0, 0, 0, 1, 1, $year));
-                $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
-                $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year);
-                $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts, false);
-            } else {
-                if ($day) {
-                    $ts = mktime(0, 0, 0, $month, $day, $year);
-                    $te = mktime(23, 59, 59, $month, $day, $year);
-                    $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
-                } else {
-                    $ts = mktime(0, 0, 0, $month, 1, $year);
-                    $te = mktime(23, 59, 59, $month, date('t', $ts), $year);
-                    $date = serendipity_formatTime('%B %Y', $ts, $false);
-                }
-            }
+            $gday = 1;
             break;
         
         case 'jalali-utf8':
             require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
             $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
+            $gday            = 1;
             
             if ($week) {
-                list ( $year, $month, $day ) = j2g($year, $month, $day);
-                $tm = strtotime('+ '. ($week-2) .' WEEKS saturday', mktime(0, 0, 0, 1, 1, $year));
-                $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
-                $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year);
-                $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts, false);
+                list( $year, $month, $day ) = j2g($year, $month, $day);
             } else {
                 if ($day) {
-                    list ( $year, $month, $day ) = j2g($year, $month, $day);
-                    $ts = mktime(0, 0, 0, $month, $day, $year);
-                    $te = mktime(23, 59, 59, $month, $day, $year);
-                    $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
+                    list( $year, $month, $day ) = j2g($year, $month, $day);
                 } else {
-                    $jm = $month;
-                    $jy = $year;
-                    list ( $year, $month, $gday ) = j2g($jy, $jm, 1);
-                    $ts = mktime(0, 0, 0, $month, $gday, $year);
-                    if ($jy%4 == 3 && $jm == 12){
-                        $nrOfDays = list ( $year, $month, $gday ) = j2g($jy, $jm, $j_days_in_month[(int)$jm]+1);
+                    if ($year % 4 == 3 && $month == 12){
+                        $nrOfDays = list( $year, $month, $gday ) = j2g($year, $month, $j_days_in_month[(int)$month]+1);
                     }else{
-                        list ( $year, $month, $gday ) = j2g($jy, $jm, $j_days_in_month[(int)$jm]);
+                        list( $year, $month, $gday ) = j2g($year, $month, $j_days_in_month[(int)$month]);
                     }
-                    $te = mktime(23, 59, 59, $month, $gday, $year);
-                    $date = serendipity_formatTime('%B %Y', $ts, $false);
+                    $gday2 = $gday;
                 }
             }
             break;
     }
 
+    if ($week) {
+        $tm = strtotime('+ '. ($week-2) .' WEEKS monday', mktime(0, 0, 0, 1, 1, $year));
+        $ts = mktime(0, 0, 0, date('m', $tm), date('j', $tm), $year);
+        $te = mktime(23, 59, 59, date('m', $tm), date('j', $tm)+7, $year);
+        $date = serendipity_formatTime(WEEK .' '. $week .', %Y', $ts, false);
+    } else {
+        if ($day) {
+            $ts = mktime(0, 0, 0, $month, $day, $year);
+            $te = mktime(23, 59, 59, $month, $day, $year);
+            $date = serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false);
+        } else {
+            $ts = mktime(0, 0, 0, $month, $gday, $year);
+            if (!isset($gday2)) {
+                $gday2 = date('t', $ts);
+            }
+            $te = mktime(23, 59, 59, $month, $gday2, $year);
+            $date = serendipity_formatTime('%B %Y', $ts, $false);
+        }
+    }
+
     $serendipity['range'] = array($ts, $te);
 
     if ($serendipity['GET']['action'] == 'read') {