コード例 #1
0
 public function getLabel()
 {
     // if the property is a date object converting it to a human readable representation.
     if ($this->literal instanceof EasyRdf_Literal_Date) {
         try {
             $val = $this->literal->getValue();
             return Punic\Calendar::formatDate($val, 'short');
         } catch (Exception $e) {
             trigger_error($e->getMessage(), E_USER_WARNING);
             return (string) $this->literal;
         }
     }
     return $this->literal->getValue();
 }
コード例 #2
0
ファイル: l10n.php プロジェクト: slapia/core
 /**
  * Localization
  * @param string $type Type of localization
  * @param array|int|string $data parameters for this localization
  * @param array $options
  * @return string|false
  *
  * Returns the localized data.
  *
  * Implemented types:
  *  - date
  *    - Creates a date
  *    - params: timestamp (int/string)
  *  - datetime
  *    - Creates date and time
  *    - params: timestamp (int/string)
  *  - time
  *    - Creates a time
  *    - params: timestamp (int/string)
  */
 public function l($type, $data, $options = array())
 {
     if ($type === 'firstday') {
         return $this->getFirstWeekDay();
     }
     if ($type === 'jsdate') {
         return $this->getDateFormat();
     }
     $this->init();
     $value = new DateTime();
     if ($data instanceof DateTime) {
         $value = $data;
     } elseif (is_string($data) && !is_numeric($data)) {
         $data = strtotime($data);
         $value->setTimestamp($data);
     } else {
         $value->setTimestamp($data);
     }
     // Use the language of the instance, before falling back to the current user's language
     $locale = $this->lang;
     if ($locale === null) {
         $locale = self::findLanguage();
     }
     $locale = $this->transformToCLDRLocale($locale);
     $options = array_merge(array('width' => 'long'), $options);
     $width = $options['width'];
     switch ($type) {
         case 'date':
             return Punic\Calendar::formatDate($value, $width, $locale);
         case 'datetime':
             return Punic\Calendar::formatDatetime($value, $width, $locale);
         case 'time':
             return Punic\Calendar::formatTime($value, $width, $locale);
         default:
             return false;
     }
 }
コード例 #3
0
ファイル: Concept.php プロジェクト: jneubert/Skosmos
 /**
  * Gets the creation date and modification date if available.
  * @return String containing the date information in a human readable format.
  */
 public function getDate()
 {
     $ret = '';
     $created = '';
     $modified = '';
     try {
         // finding the created properties
         if ($this->resource->get('dc11:created')) {
             $created = $this->resource->get('dc11:created')->getValue();
         } else {
             if ($this->resource->get('dc:created')) {
                 $created = $this->resource->get('dc:created')->getValue();
             }
         }
         // finding the modified properties
         if ($this->resource->get('dc11:modified')) {
             $modified = $this->resource->get('dc11:modified')->getValue();
         } else {
             if ($this->resource->get('dc:modified')) {
                 $modified = $this->resource->get('dc:modified')->getValue();
             }
         }
         // making a human readable string from the timestamps
         if ($created != '') {
             $ret = gettext('skosmos:created') . ' ' . Punic\Calendar::formatDate($created, 'short');
         }
         if ($modified != '') {
             if ($created != '') {
                 $ret .= ', ' . gettext('skosmos:modified') . ' ' . Punic\Calendar::formatDate($modified, 'short');
             } else {
                 $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . Punic\Calendar::formatDate($modified, 'short');
             }
         }
     } catch (Exception $e) {
         trigger_error($e->getMessage(), E_USER_WARNING);
         return gettext('skosmos:modified') . ' ' . (string) $this->resource->get('dc:modified') . ' ' . gettext('skosmos:created') . ' ' . (string) $this->resource->get('dc:created');
     }
     return $ret;
 }
コード例 #4
0
ファイル: Vocabulary.php プロジェクト: jneubert/Skosmos
 /**
  * Returns a list of recently changed or entirely new concepts.
  * @param string $clang content language for the labels 
  * @param string $lang UI language for the dates
  * @return Array 
  */
 public function getChangeList($prop, $clang, $lang, $offset)
 {
     $changelist = $this->getSparql()->queryChangeList($clang, $offset, $prop);
     $bydate = array();
     foreach ($changelist as $concept) {
         $concept['datestring'] = Punic\Calendar::formatDate($concept['date'], 'medium', $lang);
         $bydate[Punic\Calendar::getMonthName($concept['date'], 'wide', $lang, true) . Punic\Calendar::format($concept['date'], ' y', $lang)][strtolower($concept['prefLabel'])] = $concept;
     }
     return $bydate;
 }
コード例 #5
0
ファイル: l10n.php プロジェクト: Romua1d/core
 /**
  * Localization
  * @param string $type Type of localization
  * @param array|int|string $data parameters for this localization
  * @return String or false
  *
  * Returns the localized data.
  *
  * Implemented types:
  *  - date
  *    - Creates a date
  *    - params: timestamp (int/string)
  *  - datetime
  *    - Creates date and time
  *    - params: timestamp (int/string)
  *  - time
  *    - Creates a time
  *    - params: timestamp (int/string)
  */
 public function l($type, $data, $options = array())
 {
     if ($type === 'firstday') {
         return $this->getFirstWeekDay();
     }
     if ($type === 'jsdate') {
         return $this->getDateFormat();
     }
     $this->init();
     $value = new DateTime();
     if ($data instanceof DateTime) {
         $value = $data;
     } elseif (is_string($data) && !is_numeric($data)) {
         $data = strtotime($data);
         $value->setTimestamp($data);
     } else {
         $value->setTimestamp($data);
     }
     $locale = self::findLanguage();
     $options = array_merge(array('width' => 'long'), $options);
     $width = $options['width'];
     switch ($type) {
         case 'date':
             return Punic\Calendar::formatDate($value, $width, $locale);
             break;
         case 'datetime':
             return Punic\Calendar::formatDatetime($value, $width, $locale);
             break;
         case 'time':
             return Punic\Calendar::formatTime($value, $width, $locale);
             break;
         default:
             return false;
     }
 }