Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  // +----------------------------------------------------------------------+
   4  // | PHP Version 4                                                        |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 1997-2003 The PHP Group                                |
   7  // +----------------------------------------------------------------------+
   8  // | This source file is subject to version 2.0 of the PHP license,       |
   9  // | that is bundled with this package in the file LICENSE, and is        |
  10  // | available at through the world-wide-web at                           |
  11  // | http://www.php.net/license/2_02.txt.                                 |
  12  // | If you did not receive a copy of the PHP license and are unable to   |
  13  // | obtain it through the world-wide-web, please send a note to          |
  14  // | license@php.net so we can mail you a copy immediately.               |
  15  // +----------------------------------------------------------------------+
  16  // | Authors: Alexey Borzov <avb@php.net>                                 |
  17  // |          Adam Daniel <adaniel1@eesus.jnj.com>                        |
  18  // |          Bertrand Mansion <bmansion@mamasam.com>                     |
  19  // +----------------------------------------------------------------------+
  20  //
  21  // $Id$
  22  
  23  require_once 'HTML/QuickForm/group.php';
  24  require_once 'HTML/QuickForm/select.php';
  25  
  26  /**
  27   * Class for a group of elements used to input dates (and times).
  28   *
  29   * Inspired by original 'date' element but reimplemented as a subclass
  30   * of HTML_QuickForm_group
  31   *
  32   * @author Alexey Borzov <avb@php.net>
  33   * @access public
  34   */
  35  class HTML_QuickForm_date extends HTML_QuickForm_group
  36  {
  37      // {{{ properties
  38  
  39     /**
  40      * Various options to control the element's display.
  41      *
  42      * Currently known options are
  43      * 'language': date language
  44      * 'format': Format of the date, based on PHP's date() function.
  45      *     The following characters are recognised in format string:
  46      *       D => Short names of days
  47      *       l => Long names of days
  48      *       d => Day numbers
  49      *       M => Short names of months
  50      *       F => Long names of months
  51      *       m => Month numbers
  52      *       Y => Four digit year
  53      *       y => Two digit year
  54      *       h => 12 hour format
  55      *       H => 23 hour  format
  56      *       i => Minutes
  57      *       s => Seconds
  58      *       a => am/pm
  59      *       A => AM/PM
  60      * 'minYear': Minimum year in year select
  61      * 'maxYear': Maximum year in year select
  62      * 'addEmptyOption': Should an empty option be added to the top of
  63      *     each select box?
  64      * 'emptyOptionValue': The value passed by the empty option.
  65      * 'emptyOptionText': The text displayed for the empty option.
  66      * 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
  67      *
  68      * @access   private
  69      * @var      array
  70      */
  71      var $_options = array(
  72          'language'         => 'en',
  73          'format'           => 'dMY',
  74          'minYear'          => 2001,
  75          'maxYear'          => 2010,
  76          'addEmptyOption'   => false,
  77          'emptyOptionValue' => '',
  78          'emptyOptionText'  => '&nbsp;',
  79          'optionIncrement'  => array('i' => 1, 's' => 1)
  80      );
  81  
  82     /**
  83      * These complement separators, they are appended to the resultant HTML
  84      * @access   private
  85      * @var      array
  86      */
  87      var $_wrap = array('', '');
  88  
  89     /**
  90      * Options in different languages
  91      *
  92      * Note to potential translators: to avoid encoding problems please send
  93      * your translations with "weird" letters encoded as HTML Unicode entities
  94      *
  95      * @access   private
  96      * @var      array
  97      */
  98      var $_locale = array(
  99          'en'    => array (
 100              'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
 101              'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
 102              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
 103              'months_long'   => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
 104          ),
 105          'de'    => array (
 106              'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'),
 107              'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'),
 108              'months_short'  => array ('Jan', 'Feb', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'),
 109              'months_long'   => array ('Januar', 'Februar', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember')
 110          ),
 111          'fr'    => array (
 112              'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'),
 113              'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'),
 114              'months_short'  => array ('Jan', 'F&#xe9;v', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Ao&#xfb;t', 'Sep', 'Oct', 'Nov', 'D&#xe9;c'),
 115              'months_long'   => array ('Janvier', 'F&#xe9;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&#xfb;t', 'Septembre', 'Octobre', 'Novembre', 'D&#xe9;cembre')
 116          ),
 117          'hu'    => array (
 118              'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'),
 119              'weekdays_long' => array ('vas&#xe1;rnap', 'h&#xe9;tf&#x151;', 'kedd', 'szerda', 'cs&#xfc;t&#xf6;rt&#xf6;k', 'p&#xe9;ntek', 'szombat'),
 120              'months_short'  => array ('jan', 'feb', 'm&#xe1;rc', '&#xe1;pr', 'm&#xe1;j', 'j&#xfa;n', 'j&#xfa;l', 'aug', 'szept', 'okt', 'nov', 'dec'),
 121              'months_long'   => array ('janu&#xe1;r', 'febru&#xe1;r', 'm&#xe1;rcius', '&#xe1;prilis', 'm&#xe1;jus', 'j&#xfa;nius', 'j&#xfa;lius', 'augusztus', 'szeptember', 'okt&#xf3;ber', 'november', 'december')
 122          ),
 123          'pl'    => array (
 124              'weekdays_short'=> array ('Nie', 'Pn', 'Wt', '&#x15a;r', 'Czw', 'Pt', 'Sob'),
 125              'weekdays_long' => array ('Niedziela', 'Poniedzia&#x142;ek', 'Wtorek', '&#x15a;roda', 'Czwartek', 'Pi&#x105;tek', 'Sobota'),
 126              'months_short'  => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa&#x17a;', 'Lis', 'Gru'),
 127              'months_long'   => array ('Stycze&#x144;', 'Luty', 'Marzec', 'Kwiecie&#x144;', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpie&#x144;', 'Wrzesie&#x144;', 'Pa&#x17a;dziernik', 'Listopad', 'Grudzie&#x144;')
 128          ),
 129          'sl'    => array (
 130              'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'),
 131              'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'),
 132              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'),
 133              'months_long'   => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December')
 134          ),
 135          'ru'    => array (
 136              'weekdays_short'=> array ('&#x412;&#x441;', '&#x41f;&#x43d;', '&#x412;&#x442;', '&#x421;&#x440;', '&#x427;&#x442;', '&#x41f;&#x442;', '&#x421;&#x431;'),
 137              'weekdays_long' => array ('&#x412;&#x43e;&#x441;&#x43a;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;&#x435;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x435;&#x43b;&#x44c;&#x43d;&#x438;&#x43a;', '&#x412;&#x442;&#x43e;&#x440;&#x43d;&#x438;&#x43a;', '&#x421;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;&#x433;', '&#x41f;&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x430;', '&#x421;&#x443;&#x431;&#x431;&#x43e;&#x442;&#x430;'),
 138              'months_short'  => array ('&#x42f;&#x43d;&#x432;', '&#x424;&#x435;&#x432;', '&#x41c;&#x430;&#x440;', '&#x410;&#x43f;&#x440;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;', '&#x418;&#x44e;&#x43b;', '&#x410;&#x432;&#x433;', '&#x421;&#x435;&#x43d;', '&#x41e;&#x43a;&#x442;', '&#x41d;&#x43e;&#x44f;', '&#x414;&#x435;&#x43a;'),
 139              'months_long'   => array ('&#x42f;&#x43d;&#x432;&#x430;&#x440;&#x44c;', '&#x424;&#x435;&#x432;&#x440;&#x430;&#x43b;&#x44c;', '&#x41c;&#x430;&#x440;&#x442;', '&#x410;&#x43f;&#x440;&#x435;&#x43b;&#x44c;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;&#x44c;', '&#x418;&#x44e;&#x43b;&#x44c;', '&#x410;&#x432;&#x433;&#x443;&#x441;&#x442;', '&#x421;&#x435;&#x43d;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41e;&#x43a;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41d;&#x43e;&#x44f;&#x431;&#x440;&#x44c;', '&#x414;&#x435;&#x43a;&#x430;&#x431;&#x440;&#x44c;')
 140          ),
 141          'es'    => array (
 142              'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mi&#xe9;', 'Jue', 'Vie', 'S&#xe1;b'),
 143              'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Mi&#xe9;rcoles', 'Jueves', 'Viernes', 'S&#xe1;bado'),
 144              'months_short'  => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
 145              'months_long'   => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
 146          ),
 147          'da'    => array (
 148              'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
 149              'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
 150              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
 151              'months_long'   => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December')
 152          ),
 153          'is'    => array (
 154              'weekdays_short'=> array ('Sun', 'M&#xe1;n', '&#xde;ri', 'Mi&#xf0;', 'Fim', 'F&#xf6;s', 'Lau'),
 155              'weekdays_long' => array ('Sunnudagur', 'M&#xe1;nudagur', '&#xde;ri&#xf0;judagur', 'Mi&#xf0;vikudagur', 'Fimmtudagur', 'F&#xf6;studagur', 'Laugardagur'),
 156              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Ma&#xed;', 'J&#xfa;n', 'J&#xfa;l', '&#xc1;g&#xfa;', 'Sep', 'Okt', 'N&#xf3;v', 'Des'),
 157              'months_long'   => array ('Jan&#xfa;ar', 'Febr&#xfa;ar', 'Mars', 'Apr&#xed;l', 'Ma&#xed;', 'J&#xfa;n&#xed;', 'J&#xfa;l&#xed;', '&#xc1;g&#xfa;st', 'September', 'Okt&#xf3;ber', 'N&#xf3;vember', 'Desember')
 158          ),
 159          'it'    => array (
 160              'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'),
 161              'weekdays_long' => array ('Domenica', 'Luned&#xec;', 'Marted&#xec;', 'Mercoled&#xec;', 'Gioved&#xec;', 'Venerd&#xec;', 'Sabato'),
 162              'months_short'  => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'),
 163              'months_long'   => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre')
 164          ),
 165          'sk'    => array (
 166              'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', '&#x8a;tv', 'Pia', 'Sob'),
 167              'weekdays_long' => array ('Nede&#x17e;a', 'Pondelok', 'Utorok', 'Streda', '&#x8a;tvrtok', 'Piatok', 'Sobota'),
 168              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
 169              'months_long'   => array ('Janu&#xe1;r', 'Febru&#xe1;r', 'Marec', 'Apr&#xed;l', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'August', 'September', 'Okt&#xf3;ber', 'November', 'December')
 170          ),
 171          'cs'    => array (
 172              'weekdays_short'=> array ('Ne', 'Po', '&#xda;t', 'St', '&#x10c;t', 'P&#xe1;', 'So'),
 173              'weekdays_long' => array ('Ned&#x11b;le', 'Pond&#x11b;l&#xed;', '&#xda;ter&#xfd;', 'St&#x159;eda', '&#x10c;tvrtek', 'P&#xe1;tek', 'Sobota'),
 174              'months_short'  => array ('Led', '&#xda;no', 'B&#x159;e', 'Dub', 'Kv&#x11b;', '&#x10c;en', '&#x10c;ec', 'Srp', 'Z&#xe1;&#x159;', '&#x158;&#xed;j', 'Lis', 'Pro'),
 175              'months_long'   => array ('Leden', '&#xda;nor', 'B&#x159;ezen', 'Duben', 'Kv&#x11b;ten', '&#x10c;erven', '&#x10c;ervenec', 'Srpen', 'Z&#xe1;&#x159;&#xed;', '&#x158;&#xed;jen', 'Listopad', 'Prosinec')
 176          ),
 177          'hy'    => array (
 178              'weekdays_short'=> array ('&#x53f;&#x580;&#x56f;', '&#x535;&#x580;&#x56f;', '&#x535;&#x580;&#x584;', '&#x549;&#x580;&#x584;', '&#x540;&#x576;&#x563;', '&#x548;&#x582;&#x580;', '&#x547;&#x562;&#x569;'),
 179              'weekdays_long' => array ('&#x53f;&#x56b;&#x580;&#x561;&#x56f;&#x56b;', '&#x535;&#x580;&#x56f;&#x578;&#x582;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x535;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x549;&#x578;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x540;&#x56b;&#x576;&#x563;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x548;&#x582;&#x580;&#x562;&#x561;&#x569;', '&#x547;&#x561;&#x562;&#x561;&#x569;'),
 180              'months_short'  => array ('&#x540;&#x576;&#x57e;', '&#x553;&#x57f;&#x580;', '&#x544;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;', '&#x544;&#x575;&#x57d;', '&#x540;&#x576;&#x57d;', '&#x540;&#x56c;&#x57d;', '&#x555;&#x563;&#x57d;', '&#x54d;&#x57a;&#x57f;', '&#x540;&#x56f;&#x57f;', '&#x546;&#x575;&#x574;', '&#x534;&#x56f;&#x57f;'),
 181              'months_long'   => array ('&#x540;&#x578;&#x582;&#x576;&#x57e;&#x561;&#x580;', '&#x553;&#x565;&#x57f;&#x580;&#x57e;&#x561;&#x580;', '&#x544;&#x561;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;&#x56b;&#x56c;', '&#x544;&#x561;&#x575;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x576;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x56c;&#x56b;&#x57d;', '&#x555;&#x563;&#x578;&#x57d;&#x57f;&#x578;&#x57d;', '&#x54d;&#x565;&#x57a;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x540;&#x578;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x546;&#x578;&#x575;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x534;&#x565;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;')
 182          ),
 183          'nl'    => array (
 184              'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'),
 185              'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'),
 186              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
 187              'months_long'   => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December')
 188          ),
 189          'et'    => array (
 190              'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'),
 191              'weekdays_long' => array ('P&#xfc;hap&#xe4;ev', 'Esmasp&#xe4;ev', 'Teisip&#xe4;ev', 'Kolmap&#xe4;ev', 'Neljap&#xe4;ev', 'Reede', 'Laup&#xe4;ev'),
 192              'months_short'  => array ('Jaan', 'Veebr', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'),
 193              'months_long'   => array ('Jaanuar', 'Veebruar', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember')
 194          ),
 195          'tr'    => array (
 196              'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', '&#xc7;ar', 'Per', 'Cum', 'Cts'),
 197              'weekdays_long' => array ('Pazar', 'Pazartesi', 'Sal&#x131;', '&#xc7;ar&#x15f;amba', 'Per&#x15f;embe', 'Cuma', 'Cumartesi'),
 198              'months_short'  => array ('Ock', '&#x15e;bt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'A&#x11f;st', 'Eyl', 'Ekm', 'Ksm', 'Arlk'),
 199              'months_long'   => array ('Ocak', '&#x15e;ubat', 'Mart', 'Nisan', 'May&#x131;s', 'Haziran', 'Temmuz', 'A&#x11f;ustos', 'Eyl&#xfc;l', 'Ekim', 'Kas&#x131;m', 'Aral&#x131;k')
 200          ),
 201          'no'    => array (
 202              'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
 203              'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
 204              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'),
 205              'months_long'   => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember')
 206          ),
 207          'eo'    => array (
 208              'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', '&#x134;a&#x16D;', 'Ven', 'Sab'),
 209              'weekdays_long' => array ('Diman&#x109;o', 'Lundo', 'Mardo', 'Merkredo', '&#x134;a&#x16D;do', 'Vendredo', 'Sabato'),
 210              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'A&#x16D;g', 'Sep', 'Okt', 'Nov', 'Dec'),
 211              'months_long'   => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'A&#x16D;gusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro')
 212          ),
 213          'ua'    => array (
 214              'weekdays_short'=> array('&#x41d;&#x434;&#x43b;', '&#x41f;&#x43d;&#x434;', '&#x412;&#x442;&#x440;', '&#x421;&#x440;&#x434;', '&#x427;&#x442;&#x432;', '&#x41f;&#x442;&#x43d;', '&#x421;&#x431;&#x442;'),
 215              'weekdays_long' => array('&#x41d;&#x435;&#x434;&#x456;&#x43b;&#x44f;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x456;&#x43b;&#x43e;&#x43a;', '&#x412;&#x456;&#x432;&#x442;&#x43e;&#x440;&#x43e;&#x43a;', '&#x421;&#x435;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;', '&#x41f;\'&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x44f;', '&#x421;&#x443;&#x431;&#x43e;&#x442;&#x430;'),
 216              'months_short'  => array('&#x421;&#x456;&#x447;', '&#x41b;&#x44e;&#x442;', '&#x411;&#x435;&#x440;', '&#x41a;&#x432;&#x456;', '&#x422;&#x440;&#x430;', '&#x427;&#x435;&#x440;', '&#x41b;&#x438;&#x43f;', '&#x421;&#x435;&#x440;', '&#x412;&#x435;&#x440;', '&#x416;&#x43e;&#x432;', '&#x41b;&#x438;&#x441;', '&#x413;&#x440;&#x443;'),
 217              'months_long'   => array('&#x421;&#x456;&#x447;&#x435;&#x43d;&#x44c;', '&#x41b;&#x44e;&#x442;&#x438;&#x439;', '&#x411;&#x435;&#x440;&#x435;&#x437;&#x435;&#x43d;&#x44c;', '&#x41a;&#x432;&#x456;&#x442;&#x435;&#x43d;&#x44c;', '&#x422;&#x440;&#x430;&#x432;&#x435;&#x43d;&#x44c;', '&#x427;&#x435;&#x440;&#x432;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x43f;&#x435;&#x43d;&#x44c;', '&#x421;&#x435;&#x440;&#x43f;&#x435;&#x43d;&#x44c;', '&#x412;&#x435;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;', '&#x416;&#x43e;&#x432;&#x442;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x441;&#x442;&#x43e;&#x43f;&#x430;&#x434;', '&#x413;&#x440;&#x443;&#x434;&#x435;&#x43d;&#x44c;')
 218          ),
 219          'ro'    => array (
 220              'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'),
 221              'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'),
 222              'months_short'  => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
 223              'months_long'   => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie')
 224          ),
 225          'he'    => array (
 226              'weekdays_short'=> array ('&#1512;&#1488;&#1513;&#1493;&#1503;', '&#1513;&#1504;&#1497;', '&#1513;&#1500;&#1497;&#1513;&#1497;', '&#1512;&#1489;&#1497;&#1506;&#1497;', '&#1495;&#1502;&#1497;&#1513;&#1497;', '&#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
 227              'weekdays_long' => array ('&#1497;&#1493;&#1501; &#1512;&#1488;&#1513;&#1493;&#1503;', '&#1497;&#1493;&#1501; &#1513;&#1504;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1500;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1512;&#1489;&#1497;&#1506;&#1497;', '&#1497;&#1493;&#1501; &#1495;&#1502;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
 228              'months_short'  => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;'),
 229              'months_long'   => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;')
 230          ),
 231          'sv'    => array (
 232              'weekdays_short'=> array ('S&#xf6;n', 'M&#xe5;n', 'Tis', 'Ons', 'Tor', 'Fre', 'L&#xf6;r'),
 233              'weekdays_long' => array ('S&#xf6;ndag', 'M&#xe5;ndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf6;rdag'),
 234              'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
 235              'months_long'   => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December')
 236          ),
 237          'pt'    => array (
 238              'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
 239              'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'S&aacute;bado'),
 240              'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
 241              'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
 242          ),
 243          'tw'    => array (
 244              'weekdays_short'=> array ('&#36913;&#26085;','&#36913;&#19968;', '&#36913;&#20108;','&#36913;&#19977;', '&#36913;&#22235;','&#36913;&#20116;', '&#36913;&#20845;'),
 245              'weekdays_long' => array ('&#26143;&#26399;&#26085;', '&#26143;&#26399;&#19968;', '&#26143;&#26399;&#20108;', '&#26143;&#26399;&#19977;', '&#26143;&#26399;&#22235;', '&#26143;&#26399;&#20116;', '&#26143;&#26399;&#20845;'),
 246              'months_short'  => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;'),
 247              'months_long'   => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;')
 248          ),
 249          'pt-br' => array (
 250              'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
 251              'weekdays_long' => array ('Domingo', 'Segunda', 'Ter&ccedil;a', 'Quarta', 'Quinta', 'Sexta', 'S&aacute;bado'),
 252              'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
 253              'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
 254          )
 255      );
 256  
 257      // }}}
 258      // {{{ constructor
 259  
 260     /**
 261      * Class constructor
 262      *
 263      * @access   public
 264      * @param    string  Element's name
 265      * @param    mixed   Label(s) for an element
 266      * @param    array   Options to control the element's display
 267      * @param    mixed   Either a typical HTML attribute string or an associative array
 268      */
 269      public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null) {
 270          // TODO MDL-52313 Replace with the call to parent::__construct().
 271          HTML_QuickForm_element::__construct($elementName, $elementLabel, $attributes);
 272          $this->_persistantFreeze = true;
 273          $this->_appendName = true;
 274          $this->_type = 'date';
 275          // set the options, do not bother setting bogus ones
 276          if (is_array($options)) {
 277              foreach ($options as $name => $value) {
 278                  if ('language' == $name) {
 279                      $this->_options['language'] = isset($this->_locale[$value])? $value: 'en';
 280                  } elseif (isset($this->_options[$name])) {
 281                      if (is_array($value) && is_array($this->_options[$name])) {
 282                          $this->_options[$name] = @array_merge($this->_options[$name], $value);
 283                      } else {
 284                          $this->_options[$name] = $value;
 285                      }
 286                  }
 287              }
 288          }
 289      }
 290  
 291      /**
 292       * Old syntax of class constructor. Deprecated in PHP7.
 293       *
 294       * @deprecated since Moodle 3.1
 295       */
 296      public function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null) {
 297          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
 298          self::__construct($elementName, $elementLabel, $options, $attributes);
 299      }
 300  
 301      // }}}
 302      // {{{ _createElements()
 303  
 304      function _createElements()
 305      {
 306          $this->_separator = $this->_elements = array();
 307          $separator =  '';
 308          $locale    =& $this->_locale[$this->_options['language']];
 309          $backslash =  false;
 310          for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) {
 311              $sign = $this->_options['format'][$i];
 312              if ($backslash) {
 313                  $backslash  = false;
 314                  $separator .= $sign;
 315              } else {
 316                  $loadSelect = true;
 317                  switch ($sign) {
 318                      case 'D':
 319                          // Sunday is 0 like with 'w' in date()
 320                          $options = $locale['weekdays_short'];
 321                          break;
 322                      case 'l':
 323                          $options = $locale['weekdays_long'];
 324                          break;
 325                      case 'd':
 326                          $options = $this->_createOptionList(1, 31);
 327                          break;
 328                      case 'M':
 329                          $options = $locale['months_short'];
 330                          array_unshift($options , '');
 331                          unset($options[0]);
 332                          break;
 333                      case 'm':
 334                          $options = $this->_createOptionList(1, 12);
 335                          break;
 336                      case 'F':
 337                          $options = $locale['months_long'];
 338                          array_unshift($options , '');
 339                          unset($options[0]);
 340                          break;
 341                      case 'Y':
 342                          $options = $this->_createOptionList(
 343                              $this->_options['minYear'],
 344                              $this->_options['maxYear'],
 345                              $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
 346                          );
 347                          break;
 348                      case 'y':
 349                          $options = $this->_createOptionList(
 350                              $this->_options['minYear'],
 351                              $this->_options['maxYear'],
 352                              $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
 353                          );
 354                          array_walk($options, function(&$v, $k) {
 355                              $v = substr($v, -2);
 356                          });
 357                          break;
 358                      case 'h':
 359                          $options = $this->_createOptionList(1, 12);
 360                          break;
 361                      case 'g':
 362                          $options = $this->_createOptionList(1, 12);
 363                          array_walk($options, function(&$v, $k) {
 364                              $v = intval($v);
 365                          });
 366                          break;
 367                      case 'H':
 368                          $options = $this->_createOptionList(0, 23);
 369                          break;
 370                      case 'i':
 371                          $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']);
 372                          break;
 373                      case 's':
 374                          $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']);
 375                          break;
 376                      case 'a':
 377                          $options = array('am' => 'am', 'pm' => 'pm');
 378                          break;
 379                      case 'A':
 380                          $options = array('AM' => 'AM', 'PM' => 'PM');
 381                          break;
 382                      case 'W':
 383                          $options = $this->_createOptionList(1, 53);
 384                          break;
 385                      case '\\':
 386                          $backslash  = true;
 387                          $loadSelect = false;
 388                          break;
 389                      default:
 390                          $separator .= (' ' == $sign? '&nbsp;': $sign);
 391                          $loadSelect = false;
 392                  }
 393  
 394                  if ($loadSelect) {
 395                      if (0 < count($this->_elements)) {
 396                          $this->_separator[] = $separator;
 397                      } else {
 398                          $this->_wrap[0] = $separator;
 399                      }
 400                      $separator = '';
 401                      // Should we add an empty option to the top of the select?
 402                      if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] ||
 403                          is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) {
 404  
 405                          // Using '+' array operator to preserve the keys
 406                          if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) {
 407                              $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options;
 408                          } else {
 409                              $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options;
 410                          }
 411                      }
 412                      $this->_elements[] = new HTML_QuickForm_select($sign, null, $options, $this->getAttributes());
 413                  }
 414              }
 415          }
 416          $this->_wrap[1] = $separator . ($backslash? '\\': '');
 417      }
 418  
 419      // }}}
 420      // {{{ _createOptionList()
 421  
 422     /**
 423      * Creates an option list containing the numbers from the start number to the end, inclusive
 424      *
 425      * @param    int     The start number
 426      * @param    int     The end number
 427      * @param    int     Increment by this value
 428      * @access   private
 429      * @return   array   An array of numeric options.
 430      */
 431      function _createOptionList($start, $end, $step = 1)
 432      {
 433          for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) {
 434              $options[$i] = sprintf('%02d', $i);
 435          }
 436          return $options;
 437      }
 438  
 439      // }}}
 440      // {{{ setValue()
 441  
 442      function setValue($value)
 443      {
 444          if (empty($value)) {
 445              $value = array();
 446          } elseif (is_scalar($value)) {
 447              if (!is_numeric($value)) {
 448                  $value = strtotime($value);
 449              }
 450              // might be a unix epoch, then we fill all possible values
 451              $arr = explode('-', date('w-d-n-Y-h-H-i-s-a-A-W', (int)$value));
 452              $value = array(
 453                  'D' => $arr[0],
 454                  'l' => $arr[0],
 455                  'd' => $arr[1],
 456                  'M' => $arr[2],
 457                  'm' => $arr[2],
 458                  'F' => $arr[2],
 459                  'Y' => $arr[3],
 460                  'y' => $arr[3],
 461                  'h' => $arr[4],
 462                  'g' => $arr[4],
 463                  'H' => $arr[5],
 464                  'i' => $arr[6],
 465                  's' => $arr[7],
 466                  'a' => $arr[8],
 467                  'A' => $arr[9],
 468                  'W' => $arr[10]
 469              );
 470          }
 471          parent::setValue($value);
 472      }
 473  
 474      // }}}
 475      // {{{ toHtml()
 476  
 477      function toHtml()
 478      {
 479          include_once('HTML/QuickForm/Renderer/Default.php');
 480          $renderer = new HTML_QuickForm_Renderer_Default();
 481          $renderer->setElementTemplate('{element}');
 482          parent::accept($renderer);
 483          return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
 484      }
 485  
 486      // }}}
 487      // {{{ accept()
 488  
 489      function accept(&$renderer, $required = false, $error = null)
 490      {
 491          $renderer->renderElement($this, $required, $error);
 492      }
 493  
 494      // }}}
 495      // {{{ onQuickFormEvent()
 496  
 497      function onQuickFormEvent($event, $arg, &$caller)
 498      {
 499          if ('updateValue' == $event) {
 500              // we need to call setValue(), 'cause the default/constant value
 501              // may be in fact a timestamp, not an array
 502              return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller);
 503          } else {
 504              return parent::onQuickFormEvent($event, $arg, $caller);
 505          }
 506      }
 507  
 508      // }}}
 509  }
 510  ?>