Exemplo n.º 1
0
 /**
  * Converts value to DateTime object.
  * @param  string key
  * @param  string format
  * @return DateTime
  */
 public function asDateTime($key, $format = NULL)
 {
     $time = $this[$key];
     if ((int) $time === 0) {
         // '', NULL, FALSE, '0000-00-00', ...
         return NULL;
     }
     $dt = new DibiDateTime(is_numeric($time) ? date('Y-m-d H:i:s', $time) : $time);
     return $format === NULL ? $dt : $dt->format($format);
 }
Exemplo n.º 2
0
 /**
  * Converts value to DateTime object.
  * @param  string key
  * @param  string format
  * @return DateTime
  */
 public function asDateTime($key, $format = NULL)
 {
     $time = $this[$key];
     if (!$time instanceof DibiDateTime) {
         if ((int) $time === 0 && substr((string) $time, 0, 3) !== '00:') {
             // '', NULL, FALSE, '0000-00-00', ...
             return NULL;
         }
         $time = new DibiDateTime($time);
     }
     return $format === NULL ? $time : $time->format($format);
 }
Exemplo n.º 3
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
         case dibi::BINARY:
             return "'" . str_replace("'", "''", $value) . "'";
         case dibi::IDENTIFIER:
             return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "#m/d/Y H:i:s#" : "#m/d/Y#");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 4
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
         case dibi::BINARY:
             return "'" . str_replace("'", "''", $value) . "'";
             // TODO: not tested
         // TODO: not tested
         case dibi::IDENTIFIER:
             // @see http://download.oracle.com/docs/cd/B10500_01/server.920/a96540/sql_elements9a.htm
             return '"' . str_replace('"', '""', $value) . '"';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? $this->fmtDateTime : $this->fmtDate);
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
             return "'" . $this->connection->escapeString($value) . "'";
         case dibi::BINARY:
             return "X'" . bin2hex((string) $value) . "'";
         case dibi::IDENTIFIER:
             return '[' . strtr($value, '[]', '  ') . ']';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? $this->fmtDateTime : $this->fmtDate);
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 6
0
 function __construct($val)
 {
     parent::__construct($val);
     trigger_error(__CLASS__ . ' is deprecated; use class DateTime instead.', E_USER_WARNING);
 }
Exemplo n.º 7
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
             if (!is_resource($this->connection)) {
                 throw new DibiException('Lost connection to server.');
             }
             return "'" . pg_escape_string($this->connection, $value) . "'";
         case dibi::BINARY:
             if (!is_resource($this->connection)) {
                 throw new DibiException('Lost connection to server.');
             }
             return "'" . pg_escape_bytea($this->connection, $value) . "'";
         case dibi::IDENTIFIER:
             // @see http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
             return '"' . str_replace('"', '""', $value) . '"';
         case dibi::BOOL:
             return $value ? 'TRUE' : 'FALSE';
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 8
0
 function __construct($val)
 {
     parent::__construct($val);
 }
Exemplo n.º 9
0
 /**
  * Converts value to specified type and format.
  * @param  mixed  value
  * @param  int    type
  * @return mixed
  */
 protected function convert($value, $type)
 {
     if ($value === NULL || $value === FALSE) {
         return NULL;
     }
     switch ($type) {
         case dibi::TEXT:
             return (string) $value;
         case dibi::BINARY:
             return $this->getDriver()->unescape($value, $type);
         case dibi::INTEGER:
             return is_float($tmp = $value * 1) ? $value : $tmp;
         case dibi::FLOAT:
             return (double) $value;
         case dibi::DATE:
         case dibi::DATETIME:
             if ((int) $value === 0) {
                 // '', NULL, FALSE, '0000-00-00', ...
                 return NULL;
             } elseif ($this->dateFormat === '') {
                 // return DateTime object (default)
                 return new DibiDateTime(is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value);
             } elseif ($this->dateFormat === 'U') {
                 // return timestamp
                 return is_numeric($value) ? (int) $value : strtotime($value);
             } elseif (is_numeric($value)) {
                 // formatted date
                 return date($this->dateFormat, $value);
             } else {
                 $value = new DibiDateTime($value);
                 return $value->format($this->dateFormat);
             }
         case dibi::BOOL:
             return (bool) $value && $value !== 'f' && $value !== 'F';
         default:
             return $value;
     }
 }
Exemplo n.º 10
0
 public function generateAllTimes($times = 30, $term_id = 0, $limit = 120)
 {
     $limit = new DibiDateTime(strtotime('+' . $limit . ' days', time()));
     dibi::begin();
     if ($term_id) {
         dibi::query('DELETE FROM event_time_all WHERE event_time_id = %i', $term_id);
         // smaze tabulku casu s daným ID termínu
         $res = dibi::select('*, DATEDIFF(event_time.date_to, event_time.date_from) AS diff_dates')->from('event_time')->where('visible', '=', '1')->where('id', '=', $term_id)->fetchAll();
     } else {
         //dibi::query('TRUNCATE TABLE event_time_all'); // smaze celou tabulku casu
         dibi::query('UPDATE event_time SET visible = 0 WHERE (DATEDIFF(event_time.date_from, CURDATE()) < 0 AND DATEDIFF(event_time.date_to, CURDATE()) < 0) OR (DATEDIFF(event_time.date_from, CURDATE()) < 0 AND isnull(`event_time`.`date_to`))');
         // prevede vsechny starsi casy do neaktivni polohy
         $res = dibi::select('*, DATEDIFF(event_time.date_to, event_time.date_from) AS diff_dates')->from('event_time')->where('visible', '=', '1')->fetchAll();
     }
     foreach ($res as $key => $event) {
         $interval = date_diff($event->date_from, date_create());
         if ($interval->days > 0 && $interval->invert) {
             $date_from = $event->date_from;
             //dump('od '.$date_from);
         } else {
             $date_from = new DibiDateTime();
             //dump('od dnes');
         }
         $nextmonday = new DibiDateTime(date('N', strtotime('today')) == 1 ? strtotime('today') : strtotime('next monday', $date_from->getTimestamp()));
         $nexttuesday = new DibiDateTime(date('N', strtotime('today')) == 2 ? strtotime('today') : strtotime('next tuesday', $date_from->getTimestamp()));
         $nextwednesday = new DibiDateTime(date('N', strtotime('today')) == 3 ? strtotime('today') : strtotime('next wednesday', $date_from->getTimestamp()));
         $nextthursday = new DibiDateTime(date('N', strtotime('today')) == 4 ? strtotime('today') : strtotime('next thursday', $date_from->getTimestamp()));
         $nextfriday = new DibiDateTime(date('N', strtotime('today')) == 5 ? strtotime('today') : strtotime('next friday', $date_from->getTimestamp()));
         $nextsaturday = new DibiDateTime(date('N', strtotime('today')) == 6 ? strtotime('today') : strtotime('next saturday', $date_from->getTimestamp()));
         $nextsunday = new DibiDateTime(date('N', strtotime('today')) == 7 ? strtotime('today') : strtotime('next sunday', $date_from->getTimestamp()));
         //dump($date_from);
         if ($event->repeat == 1) {
             if ($event->every_monday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextmonday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_tuesday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nexttuesday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_wednesday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextwednesday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_thursday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextthursday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_friday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextfriday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_saturday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextsaturday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
             if ($event->every_sunday == 1) {
                 for ($i = 0; $i < $times * 7; $i = $i + 7) {
                     $day = new DibiDateTime(strtotime('+' . $i . ' days', $nextsunday->getTimestamp()));
                     if ($day->getTimestamp() > $limit->getTimestamp()) {
                         continue;
                     }
                     $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $day . "', '" . $event->date_to . "'); \r\n";
                     dibi::query($query);
                 }
             }
         } else {
             $query = "INSERT IGNORE INTO event_time_all (event_time_id, date_from, date_to) VALUES ('" . $event->id . "', '" . $event->date_from . "', '" . $event->date_to . "'); \r\n";
             dibi::query($query);
         }
     }
     dibi::query('DELETE FROM event_time_all WHERE date_to < date_from AND date_to !="0000-00-00"');
     dibi::commit();
 }
Exemplo n.º 11
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
             if (!is_resource($this->connection)) {
                 throw new DibiException('Lost connection to server.');
             }
             return "'" . mysql_real_escape_string($value, $this->connection) . "'";
         case dibi::BINARY:
             if (!is_resource($this->connection)) {
                 throw new DibiException('Lost connection to server.');
             }
             return "_binary'" . mysql_real_escape_string($value, $this->connection) . "'";
         case dibi::IDENTIFIER:
             // @see http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
             return '`' . str_replace('`', '``', $value) . '`';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 12
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
             return $this->connection->quote($value, PDO::PARAM_STR);
         case dibi::BINARY:
             return $this->connection->quote($value, PDO::PARAM_LOB);
         case dibi::IDENTIFIER:
             switch ($this->driverName) {
                 case 'mysql':
                     return '`' . str_replace('`', '``', $value) . '`';
                 case 'pgsql':
                     return '"' . str_replace('"', '""', $value) . '"';
                 case 'sqlite':
                 case 'sqlite2':
                     return '[' . strtr($value, '[]', '  ') . ']';
                 case 'odbc':
                 case 'oci':
                     // TODO: not tested
                 // TODO: not tested
                 case 'mssql':
                     return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
                 case 'sqlsrv':
                     return '[' . str_replace(']', ']]', $value) . ']';
                 default:
                     return $value;
             }
         case dibi::BOOL:
             return $this->connection->quote($value, PDO::PARAM_BOOL);
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 13
0
 /**
  * Converts values to specified type and format.
  * @param  array
  * @return void
  */
 private function normalize(array &$row)
 {
     foreach ($this->types as $key => $type) {
         if (!isset($row[$key])) {
             // NULL
             continue;
         }
         $value = $row[$key];
         if ($value === FALSE || $type === dibi::TEXT) {
         } elseif ($type === dibi::INTEGER) {
             $row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
         } elseif ($type === dibi::FLOAT) {
             $row[$key] = (string) ($tmp = (double) $value) === rtrim(rtrim($value, '0'), '.') ? $tmp : $value;
         } elseif ($type === dibi::BOOL) {
             $row[$key] = (bool) $value && $value !== 'f' && $value !== 'F';
         } elseif ($type === dibi::DATE || $type === dibi::DATETIME) {
             if ((int) $value === 0 && substr((string) $value, 0, 3) !== '00:') {
                 // '', NULL, FALSE, '0000-00-00', ...
             } elseif (empty($this->formats[$type])) {
                 // return DateTime object (default)
                 $row[$key] = new DibiDateTime(is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value);
             } elseif ($this->formats[$type] === 'U') {
                 // return timestamp
                 $row[$key] = is_numeric($value) ? (int) $value : strtotime($value);
             } elseif (is_numeric($value)) {
                 // formatted date
                 $row[$key] = date($this->formats[$type], $value);
             } else {
                 $value = new DibiDateTime($value);
                 $row[$key] = $value->format($this->formats[$type]);
             }
         } elseif ($type === dibi::BINARY) {
             $row[$key] = $this->getResultDriver()->unescape($value, $type);
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
             return "'" . mysqli_real_escape_string($this->connection, $value) . "'";
         case dibi::BINARY:
             return "_binary'" . mysqli_real_escape_string($this->connection, $value) . "'";
         case dibi::IDENTIFIER:
             return '`' . str_replace('`', '``', $value) . '`';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 15
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
         case dibi::BINARY:
             if ($this->driverName === 'odbc') {
                 return "'" . str_replace("'", "''", $value) . "'";
             } else {
                 return $this->connection->quote($value, $type === dibi::TEXT ? PDO::PARAM_STR : PDO::PARAM_LOB);
             }
         case dibi::IDENTIFIER:
             switch ($this->driverName) {
                 case 'mysql':
                     return '`' . str_replace('`', '``', $value) . '`';
                 case 'oci':
                 case 'pgsql':
                     return '"' . str_replace('"', '""', $value) . '"';
                 case 'sqlite':
                 case 'sqlite2':
                     return '[' . strtr($value, '[]', '  ') . ']';
                 case 'odbc':
                 case 'mssql':
                     return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
                 case 'sqlsrv':
                     return '[' . str_replace(']', ']]', $value) . ']';
                 default:
                     return $value;
             }
         case dibi::BOOL:
             if ($this->driverName === 'pgsql') {
                 return $value ? 'TRUE' : 'FALSE';
             } else {
                 return $value ? 1 : 0;
             }
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             if ($this->driverName === 'odbc') {
                 return $value->format($type === dibi::DATETIME ? "#m/d/Y H:i:s#" : "#m/d/Y#");
             } else {
                 return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
             }
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 16
0
 /**
  * Encodes data for use in a SQL statement.
  * @param  mixed     value
  * @param  string    type (dibi::TEXT, dibi::BOOL, ...)
  * @return string    encoded value
  * @throws InvalidArgumentException
  */
 public function escape($value, $type)
 {
     switch ($type) {
         case dibi::TEXT:
         case dibi::BINARY:
             return "'" . str_replace("'", "''", $value) . "'";
         case dibi::IDENTIFIER:
             // @see https://msdn.microsoft.com/en-us/library/ms176027.aspx
             return '[' . str_replace(array('[', ']'), array('[[', ']]'), $value) . ']';
         case dibi::BOOL:
             return $value ? 1 : 0;
         case dibi::DATE:
         case dibi::DATETIME:
             if (!$value instanceof DateTime && !$value instanceof DateTimeInterface) {
                 $value = new DibiDateTime($value);
             }
             return $value->format($type === dibi::DATETIME ? "'Y-m-d H:i:s'" : "'Y-m-d'");
         default:
             throw new InvalidArgumentException('Unsupported type.');
     }
 }
Exemplo n.º 17
0
 /**
  * Converts values to specified type and format.
  * @param  array
  * @return void
  */
 private function normalize(array &$row)
 {
     foreach ($this->types as $key => $type) {
         if (!isset($row[$key])) {
             // NULL
             continue;
         }
         $value = $row[$key];
         if ($value === FALSE || $type === dibi::TEXT) {
         } elseif ($type === dibi::INTEGER) {
             $row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
         } elseif ($type === dibi::FLOAT) {
             $row[$key] = str_replace(',', '.', ltrim((string) ($tmp = (double) $value), '0')) === ltrim(rtrim(rtrim($value, '0'), '.'), '0') ? $tmp : $value;
         } elseif ($type === dibi::BOOL) {
             $row[$key] = (bool) $value && $value !== 'f' && $value !== 'F';
         } elseif ($type === dibi::DATE || $type === dibi::DATETIME) {
             if ((int) $value !== 0 || substr((string) $value, 0, 3) === '00:') {
                 // '', NULL, FALSE, '0000-00-00', ...
                 $value = new DibiDateTime($value);
                 $row[$key] = empty($this->formats[$type]) ? $value : $value->format($this->formats[$type]);
             }
         } elseif ($type === dibi::BINARY) {
             $row[$key] = $this->getResultDriver()->unescape($value, $type);
         }
     }
 }
Exemplo n.º 18
0
 private function getFlags(&$item)
 {
     $created = new \DibiDateTime($item['created']);
     $changed = new \DibiDateTime($item['changed']);
     $days_created = round((time() - $created->getTimestamp()) / 60 / 60 / 24);
     $days_changed = round((time() - $changed->getTimestamp()) / 60 / 60 / 24);
     if ($days_created < $this->new_days) {
         $item['is_created'] = true;
     } else {
         $item['is_created'] = false;
     }
     if ($days_changed < $this->updated_days) {
         $item['is_changed'] = true;
     } else {
         $item['is_changed'] = false;
     }
 }