Esempio n. 1
0
 /**
  * Convert some common fields to local timezone.
  *
  * @param   object  $item    The item data object.
  * @param   array   $fields  The fields we want to convert.
  *
  * @return  object  Return converted data.
  */
 public static function itemDatesToLocal($item, array $fields = null)
 {
     if (!is_object($item)) {
         throw new \InvalidArgumentException('Item should be object.');
     }
     if (!$fields) {
         $fields = array('created', 'publish_up', 'publish_down', 'modified');
     }
     foreach ($fields as $field) {
         if (property_exists($item, $field)) {
             $item->{$field} = DateHelper::toLocalTime($item->{$field});
         }
     }
 }