X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FDateAndTime.class.php;h=20f274265a7762ca3c64b4865fe15c68b662e324;hb=f787edd7045299de3885c052d243b446f7324ea0;hp=26a51c582c59649dedee2e6c4510b791c9628670;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/DateAndTime.class.php b/WEB-INF/lib/DateAndTime.class.php index 26a51c58..20f27426 100644 --- a/WEB-INF/lib/DateAndTime.class.php +++ b/WEB-INF/lib/DateAndTime.class.php @@ -182,10 +182,10 @@ class DateAndTime { var $mMinute = 0; var $mSecond = 0; var $mMonth; - var $mDay; // day of week - var $mDate; // day of month + var $mDay; // day of week + var $mDate; // day of month var $mYear; - var $mIntrFormat = "%d.%m.%Y %H:%M:%S"; //29.02.2004 16:21:42 internal format date + var $mIntrFormat = "%d.%m.%Y %H:%M:%S"; //29.02.2004 16:21:42 internal format date var $mLocalFormat; var $mParseResult = 0; var $mAutoComplete = true; @@ -197,7 +197,7 @@ class DateAndTime { * @param String $strfDateTime * @return DateAndTime */ - function DateAndTime($format="",$strfDateTime="") { + function __construct($format="",$strfDateTime="") { $this->mLocalFormat = ($format ? $format : $this->mIntrFormat); $d = ($strfDateTime ? $strfDateTime : $this->do_strftime($this->mLocalFormat)); $this->parseVal($d); @@ -287,27 +287,17 @@ class DateAndTime { } function isError() { - if ($this->mParseResult!=0) return true; + if ($this->mParseResult != 0) return true; return false; } - function getClone() { - if (version_compare(phpversion(), '5.0') < 0) { - $d = new DateAndTime($this->getFormat()); - $d->setTimestamp($this->getTimestamp()); - return $d; - } else { - return clone($this); - } - } - function before(/*DateAndTime*/ $obj) { - if ($this->getTimestamp()<$obj->getTimestamp()) return true; + if ($this->getTimestamp() < $obj->getTimestamp()) return true; return false; } function after(/*DateAndTime*/ $obj) { - if ($this->getTimestamp()>$obj->getTimestamp()) return true; + if ($this->getTimestamp() > $obj->getTimestamp()) return true; return false; } @@ -316,12 +306,6 @@ class DateAndTime { return false; } - function nextDate() { - $d = $this->getClone(); - $d->incDay(); - return $d; - } - function decDay(/*int*/$days=1) { $this->setTimestamp(@mktime($this->mHour, $this->mMinute, $this->mSecond, $this->mMonth, $this->mDate - $days, $this->mYear)); } @@ -337,18 +321,17 @@ class DateAndTime { */ function preprocessFormatString($format) { global $i18n; - if (isset($GLOBALS['i18n'])) { - // replace locale-dependent strings - $format = str_replace('%a', mb_substr($i18n->getWeekDayName($this->mDay), 0, 3, 'utf-8'), $format); - $format = str_replace('%A', $i18n->getWeekDayName($this->mDay), $format); - $abbrev_month = mb_substr($i18n->monthNames[$this->mMonth], 0, 3, 'utf-8'); - $format = str_replace('%b', $abbrev_month, $format); - $format = str_replace('%h', $abbrev_month, $format); - $format = str_replace('%z', date('O'), $format); - $format = str_replace('%Z', date('O'), $format); // format as 'O' for consistency with JS strftime - if (strpos($format, '%c') !== false) { - $format = str_replace('%c', $this->preprocessFormatString('%a %d %b %Y %T %Z'), $format); - } + + // replace locale-dependent strings + $format = str_replace('%a', mb_substr($i18n->getWeekDayName($this->mDay), 0, 3, 'utf-8'), $format); + $format = str_replace('%A', $i18n->getWeekDayName($this->mDay), $format); + $abbrev_month = mb_substr($i18n->monthNames[$this->mMonth], 0, 3, 'utf-8'); + $format = str_replace('%b', $abbrev_month, $format); + $format = str_replace('%h', $abbrev_month, $format); + $format = str_replace('%z', date('O'), $format); + $format = str_replace('%Z', date('O'), $format); // format as 'O' for consistency with JS strftime + if (strpos($format, '%c') !== false) { + $format = str_replace('%c', $this->preprocessFormatString('%a %d %b %Y %T %Z'), $format); } return $format; } @@ -362,4 +345,3 @@ class DateAndTime { } } } -?> \ No newline at end of file