From fbf2d311802c232f400bb22774a384e8e91d43fd Mon Sep 17 00:00:00 2001 From: omidmottaghi Date: Wed, 12 Apr 2006 04:17:16 +0000 Subject: [PATCH] some bugs in persian_mktime temporary fixed! --- include/functions_calendars.inc.php | 42 +++++++++++++++++++++++------ index.php | 2 +- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/include/functions_calendars.inc.php b/include/functions_calendars.inc.php index e25ffae..4db62d7 100644 --- a/include/functions_calendars.inc.php +++ b/include/functions_calendars.inc.php @@ -2,11 +2,6 @@ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details -if (defined('S9Y_FRAMEWORK_CALENDARS')) { - return; -} -@define('S9Y_FRAMEWORK_CALENDARS', true); - /** * Gregorian to Persian Convertor * @@ -265,9 +260,13 @@ function persian_strftime_utf($format, $timestamp) { * @param int Timestamp to format * @return string Formatted local time/date */ -function persian_date_utf($format, $timestamp) { +function persian_date_utf($format, $timestamp='') { - $g_d=date('j', $timestamp); + if($timestamp==''){ + $timestamp = mktime(); + } + + $g_d=date('j', $timestamp); $g_m=date('n', $timestamp); $g_y=date('Y', $timestamp); @@ -417,6 +416,7 @@ function persian_date_utf($format, $timestamp) { /** * Create a Unix timestamp for a Persian date + * This function only works with month >= 0 and day > 0 * * @author Omid Mottaghi * @access public @@ -429,7 +429,33 @@ function persian_date_utf($format, $timestamp) { * @param int is daylight savings time set? * @return int returned timestamp */ -function persian_mktime($hour=0, $min=0, $sec=0, $mon=1, $day=1, $year=1349, $is_dst=-1){ +function persian_mktime($hour='', $min='', $sec='', $mon='', $day='', $year='', $is_dst=-1){ + if ( (string) $hour == '') { $hour = persian_date_utf('H'); } + if ( (string) $min == '') { $min = persian_date_utf('i'); } + if ( (string) $sec == '') { $sec = persian_date_utf('s'); } + if ( (string) $day == '') { $day = persian_date_utf('j'); } + if ( (string) $mon == '') { $mon = persian_date_utf('n'); } + if ( (string) $year == '') { $year = persian_date_utf('Y'); } + + // these lines is temporary + if($mon == 0){ + $year --; + $mon = 12; + } + + /*if($mon <= 0){ + // change sign and plus one! + $mon = abs($mon) + 1; + echo $mon.'
'; + // calculate years and months that should be decreased + $years = floor($mon/12) + 1; + $months = ($years*12) - $mon + 1; + echo $years.'
'; + die($months); + $year -= $years; + $mon = $months; + }*/ + list($year, $mon, $day)=p2g($year, $mon, $day); return mktime($hour, $min, $sec, $mon, $day, $year, $is_dst); } diff --git a/index.php b/index.php index 561b24c..230b7a5 100644 --- a/index.php +++ b/index.php @@ -190,7 +190,7 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range } } - list($year, $month, $day) = j2g ($year, $month, $day); + list($year, $month, $day) = p2g ($year, $month, $day); break; } -- 2.39.5