cvs: pear /Date Date.php
| From: | Baba Buehler | Date: | Wed, 14 Aug 2002 05:43:10 +0000 |
| Subject: | cvs: pear /Date Date.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-5730@lists.php.net to get a copy of this message | ||
baba Wed Aug 14 01:43:10 2002 EDT
Modified files:
/pear/Date Date.php
Log:
incorporated patches from Nathan Fredrickson <nathan@silverorange.com>
off-by-one hour errors in format()'s %I %P %p and %r outputs
incorrect variable used in setMinute() method
Index: pear/Date/Date.php
diff -u pear/Date/Date.php:1.4 pear/Date/Date.php:1.5
--- pear/Date/Date.php:1.4 Fri Jun 21 20:58:20 2002
+++ pear/Date/Date.php Wed Aug 14 01:43:10 2002
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Date.php,v 1.4 2002/06/22 00:58:20 dallen Exp $
+// $Id: Date.php,v 1.5 2002/08/14 05:43:10 baba Exp $
//
// Date Class
//
@@ -272,7 +272,8 @@
$output .= sprintf("%02d", $this->hour);
break;
case "I":
- $output .= sprintf("%02d", ($this->hour + 1) > 12 ?
$this->hour + 1 - 12 : $this->hour + 1);
+ $hour = ($this->hour + 1) > 12 ? $this->hour - 12 :
$this->hour;
+ $output .= sprintf("%02d", $hour==0 ? 12 : $hour);
break;
case "j":
$output .=
Date_Calc::julianDate($this->day,$this->month,$this->year);
@@ -287,13 +288,14 @@
$output .= "\n";
break;
case "p":
- $output .= $this->hour > 12 ? "pm" : "am";
+ $output .= $this->hour >= 12 ? "pm" : "am";
break;
case "P":
- $output .= $this->hour > 12 ? "PM" : "AM";
+ $output .= $this->hour >= 12 ? "PM" : "AM";
break;
case "r":
- $output .= sprintf("%02d:%02d:%02d %s", $this->hour > 12 ?
$this->hour - 12 : $this->hour, $this->minute, $this->second, $this->hour > 12 ?
"PM" : "AM");
+ $hour = ($this->hour + 1) > 12 ? $this->hour - 12 :
$this->hour;
+ $output .= sprintf("%02d:%02d:%02d %s", $hour==0 ? 12 : $hour,
$this->minute, $this->second, $this->hour >= 12 ? "PM" : "AM");
break;
case "R":
$output .= sprintf("%02d:%02d", $this->hour,
$this->minute);
@@ -1006,7 +1008,7 @@
if($m > 59 || $m < 0) {
$this->minute = 0;
} else {
- $this->minute = $s;
+ $this->minute = $m;
}
}