Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

153
 
386
 
386
 
datetime.php
_> 11 <?php
  22 /*
<> 3 -  $Id: datetime.php 153 2005-08-04 12:57:59Z hpdl $
   3+  $Id: datetime.php 386 2006-01-12 11:36:39Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2004 osCommerce
   8+  Copyright (c) 2006 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
  1212 
  1313   class osC_DateTime {
<> 14 -    var $date = '',
  15 -        $month = '',
  16 -        $year = '',
  17 -        $hour = '',
  18 -        $minute = '',
  19 -        $second = '',
  20 -        $long_date_format = '',
  21 -        $short_date_format = '',
  22 -        $long_date = '',
  23 -        $short_date = '';
   14+    function getNow() {
   15+      return date('Y-m-d H:i:s');     
   16+    }
2417 
<> 25 -    function osC_DateTime($raw_date = '', $long_date_format = '', $short_date_format = '') {
  26 -      if (tep_not_null($long_date_format)) {
  27 -        $this->long_date_format = $long_date_format;
  28 -      } else {
  29 -        $this->long_date_format = DATE_FORMAT_LONG;
  30 -      }
   18+    function getShort($date = '') {
   19+      global $osC_Language;
3120 
<> 32 -      if (tep_not_null($short_date_format)) {
  33 -        $this->short_date_format = $short_date_format;
  34 -      } else {
  35 -        $this->short_date_format = DATE_FORMAT;
   21+      if (empty($date)) {
   22+        $date = osC_DateTime::getNow();
3623       }
  3724 
<> 38 -      if (tep_not_null($raw_date)) {
  39 -        $this->format($raw_date);
   25+      $year = substr($date, 0, 4);
   26+      $month = (int)substr($date, 5, 2);
   27+      $day = (int)substr($date, 8, 2);
   28+      $hour = (int)substr($date, 11, 2);
   29+      $minute = (int)substr($date, 14, 2);
   30+      $second = (int)substr($date, 17, 2);
   31+
   32+      if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
   33+        return strftime($osC_Language->getDateFormatShort(), mktime($hour, $minute, $second, $month, $day, $year));
4034       } else {
<> 41 -        $this->setCurrentDate();
   35+        return ereg_replace('2037', $year, strftime($osC_Language->getDateFormatShort(), mktime($hour, $minute, $second, $month, $day, 2037)));
4236       }
  4337     }
  4438 
<> 45 -    function setCurrentDate() {
  46 -      $this->date = date('d');
  47 -      $this->month = date('m');
  48 -      $this->year = date('Y');
   39+    function getLong($date = '') {
   40+      global $osC_Language;
4941 
<> 50 -      $this->hour = date('H');
  51 -      $this->minute = date('i');
  52 -      $this->second = date('s');
  53 -    }
  54 -
  55 -    function format($raw_date) {
  56 -      if (empty($raw_date) || ($raw_date == '0000-00-00 00:00:00')) {
  57 -        return false;
   42+      if (empty($date)) {
   43+        $date = osC_DateTime::getNow();
5844       }
  5945 
<> 60 -      $this->year = (int)substr($raw_date, 0, 4);
  61 -      $this->month = (int)substr($raw_date, 5, 2);
  62 -      $this->day = (int)substr($raw_date, 8, 2);
  63 -      $this->hour = (int)substr($raw_date, 11, 2);
  64 -      $this->minute = (int)substr($raw_date, 14, 2);
  65 -      $this->second = (int)substr($raw_date, 17, 2);
   46+      $year = substr($date, 0, 4);
   47+      $month = (int)substr($date, 5, 2);
   48+      $day = (int)substr($date, 8, 2);
   49+      $hour = (int)substr($date, 11, 2);
   50+      $minute = (int)substr($date, 14, 2);
   51+      $second = (int)substr($date, 17, 2);
6652 
<> 67 -      $this->long_date = strftime($this->long_date_format, mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year));
  68 -
  69 -      if (@date('Y', mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year)) == $this->year) {
  70 -        $this->short_date = date($this->short_date_format, mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year));
   53+      if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
   54+        return strftime($osC_Language->getDateFormatLong(), mktime($hour, $minute, $second, $month, $day, $year));
7155       } else {
<> 72 -        $this->short_date = ereg_replace('2037$', $this->year, date($this->short_date_format, mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, 2037)));
   56+        return ereg_replace('2037', $year, strftime($osC_Language->getDateFormatLong(), mktime($hour, $minute, $second, $month, $day, 2037)));
<_ 7357       }
  7458     }
  7559