From 124c30730a3c270060aa0b6b8e44ee309cd5b852 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Mon, 4 Jul 2005 12:14:18 +0000 Subject: [PATCH] Omid, please try to keep code duplication to a minimum. See seperate mail on the mailinglist. --- index.php | 62 +++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/index.php b/index.php index c89d971..a85199b 100644 --- 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') { -- 2.39.5