Exemplo n.º 1
0
 /**
  * Retrieve the relative day name (eg 'yesterday', 'tomorrow'), if available
  * @param \DateTime $datetime The date for which you want the relative day name
  * @param bool $ucFirst = false Force first letter to be upper case?
  * @param string $locale = '' The locale to use. If empty we'll use the default locale set in \Punic\Data
  * @return Returns the relative name if available, otherwise returns an empty string
  */
 public static function getDateRelativeName($datetime, $ucFirst = false, $locale = '')
 {
     $result = '';
     $deltaDays = static::getDeltaDays($datetime);
     $data = \Punic\Data::get('dateFields', $locale);
     if (array_key_exists('day', $data)) {
         $data = $data['day'];
         $key = "relative-type-{$deltaDays}";
         if (array_key_exists($key, $data)) {
             $result = $data[$key];
             if ($ucFirst) {
                 $result = \Punic\Misc::fixCase($result, 'titlecase-firstword');
             }
         }
     }
     return $result;
 }