vendor/amenadiel/jpgraph/src/util/DateLocale.php line 61

  1. <?php
  2. /**
  3.  * JPGraph v4.0.3
  4.  */
  5. namespace Amenadiel\JpGraph\Util;
  6. /**
  7.  * @class DateLocale
  8.  * // Description: Hold localized text used in dates
  9.  */
  10. class DateLocale
  11. {
  12.     public $iLocale 'C'// environmental locale be used by default
  13.     private $iDayAbb;
  14.     private $iShortDay;
  15.     private $iShortMonth;
  16.     private $iMonthName;
  17.     public function __construct()
  18.     {
  19.         settype($this->iDayAbb'array');
  20.         settype($this->iShortDay'array');
  21.         settype($this->iShortMonth'array');
  22.         settype($this->iMonthName'array');
  23.         $this->Set('C');
  24.     }
  25.     public function Set($aLocale)
  26.     {
  27.         if (in_array($aLocalearray_keys($this->iDayAbb), true)) {
  28.             $this->iLocale $aLocale;
  29.             return true// already cached nothing else to do!
  30.         }
  31.         $pLocale setlocale(LC_TIME0); // get current locale for LC_TIME
  32.         if (is_array($aLocale)) {
  33.             foreach ($aLocale as $loc) {
  34.                 $res = @setlocale(LC_TIME$loc);
  35.                 if ($res) {
  36.                     $aLocale $loc;
  37.                     break;
  38.                 }
  39.             }
  40.         } else {
  41.             $res = @setlocale(LC_TIME$aLocale);
  42.         }
  43.         if (!$res) {
  44.             JpGraphError::RaiseL(25007$aLocale);
  45.             //("You are trying to use the locale ($aLocale) which your PHP installation does not support. Hint: Use '' to indicate the default locale for this geographic region.");
  46.             return false;
  47.         }
  48.         $this->iLocale $aLocale;
  49.         for ($i 0$ofs strftime('%w'); $i 7$i++, $ofs++) {
  50.             $day                         strftime('%a'strtotime("${ofs} day"));
  51.             $day[0]                      = strtoupper($day[0]);
  52.             $this->iDayAbb[$aLocale][]   = $day[0];
  53.             $this->iShortDay[$aLocale][] = $day;
  54.         }
  55.         for ($i 1$i <= 12; ++$i) {
  56.             list($short$full)            = explode('|'strftime('%b|%B'strtotime("2001-${i}-01")));
  57.             $this->iShortMonth[$aLocale][] = ucfirst($short);
  58.             $this->iMonthName[$aLocale][]  = ucfirst($full);
  59.         }
  60.         setlocale(LC_TIME$pLocale);
  61.         return true;
  62.     }
  63.     public function GetDayAbb()
  64.     {
  65.         return $this->iDayAbb[$this->iLocale];
  66.     }
  67.     public function GetShortDay()
  68.     {
  69.         return $this->iShortDay[$this->iLocale];
  70.     }
  71.     public function GetShortMonth()
  72.     {
  73.         return $this->iShortMonth[$this->iLocale];
  74.     }
  75.     public function GetShortMonthName($aNbr)
  76.     {
  77.         return $this->iShortMonth[$this->iLocale][$aNbr];
  78.     }
  79.     public function GetLongMonthName($aNbr)
  80.     {
  81.         return $this->iMonthName[$this->iLocale][$aNbr];
  82.     }
  83.     public function GetMonth()
  84.     {
  85.         return $this->iMonthName[$this->iLocale];
  86.     }
  87. }