Skip to content
Browse files

(Fixes issue 637)

  • Loading branch information...
1 parent 11ed769 commit 8cf40b25254cafebf73fe01e3a207d8d119bed93 qiang.xue committed
Showing with 2 additions and 96 deletions.
  1. +1 −0 CHANGELOG
  2. +1 −96 framework/utils/CTimestamp.php
View
1 CHANGELOG
@@ -5,6 +5,7 @@
Version 1.0.11 to be released
-----------------------------
- Bug #608: yiic webapp command may generate incorrect path referring to yii scripts (Qiang)
+- Bug #637: CDateTimeParser::parse() may generate unexpected result offset by the timezone in some environment (Qiang)
- Bug #639: CJSON::decode() should respect the second parameter recursively (Qiang)
- Bug #641: CDbCache::gc() is not defined (Qiang)
- Bug #651: Fixed a bug in Oracle driver that may cause big loop (Qiang)
View
97 framework/utils/CTimestamp.php
@@ -384,101 +384,6 @@ public static function getTimestamp($hr,$min,$sec,$mon=false,$day=false,$year=fa
{
if ($mon === false)
return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec);
-
- // for windows, we don't check 1970 because with timezone differences,
- // 1 Jan 1970 could generate negative timestamp, which is illegal
- if (1971 <= $year && $year < 2038)
- {
- return $is_gmt ? @gmmktime($hr,$min,$sec,$mon,$day,$year)
- : @mktime($hr,$min,$sec,$mon,$day,$year);
- }
-
- $gmt_different = ($is_gmt) ? 0 : self::getGMTDiff();
-
- /*
- # disabled because some people place large values in $sec.
- # however we need it for $mon because we use an array...
- $hr = intval($hr);
- $min = intval($min);
- $sec = intval($sec);
- */
- $mon = intval($mon);
- $day = intval($day);
- $year = intval($year);
-
-
- $year = self::digitCheck($year);
-
- if ($mon > 12)
- {
- $y = floor($mon / 12);
- $year += $y;
- $mon -= $y*12;
- }
- else if ($mon < 1)
- {
- $y = ceil((1-$mon) / 12);
- $year -= $y;
- $mon += $y*12;
- }
-
- $_day_power = 86400;
- $_hour_power = 3600;
- $_min_power = 60;
-
- $_month_table_normal = & self::$_monthNormal;
- $_month_table_leaf = & self::$_monthLeaf;
-
- $_total_date = 0;
- if ($year >= 1970)
- {
- for ($a = 1970 ; $a <= $year; $a++)
- {
- $leaf = self::isLeapYear($a);
- if ($leaf == true) {
- $loop_table = $_month_table_leaf;
- $_add_date = 366;
- } else {
- $loop_table = $_month_table_normal;
- $_add_date = 365;
- }
- if ($a < $year) {
- $_total_date += $_add_date;
- } else {
- for($b=1;$b<$mon;$b++) {
- $_total_date += $loop_table[$b];
- }
- }
- }
- $_total_date +=$day-1;
- $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different;
-
- } else {
- for ($a = 1969 ; $a >= $year; $a--) {
- $leaf = self::isLeapYear($a);
- if ($leaf == true) {
- $loop_table = $_month_table_leaf;
- $_add_date = 366;
- } else {
- $loop_table = $_month_table_normal;
- $_add_date = 365;
- }
- if ($a > $year) { $_total_date += $_add_date;
- } else {
- for($b=12;$b>$mon;$b--) {
- $_total_date += $loop_table[$b];
- }
- }
- }
- $_total_date += $loop_table[$mon] - $day;
-
- $_day_time = $hr * $_hour_power + $min * $_min_power + $sec;
- $_day_time = $_day_power - $_day_time;
- $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different);
- if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction
- else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582.
- }
-
- return $ret;
+ return $is_gmt ? @gmmktime($hr,$min,$sec,$mon,$day,$year) : @mktime($hr,$min,$sec,$mon,$day,$year);
}
}

0 comments on commit 8cf40b2

Please sign in to comment.
Something went wrong with that request. Please try again.