ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/user/filters/date.php000064400000012643152266357350022761 0ustar00. /** * Date filter * * @package core_user * @category user * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once($CFG->dirroot.'/user/filters/lib.php'); /** * Generic filter based on a date. * @copyright 1999 Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class user_filter_date extends user_filter_type { /** * the fields available for comparisson * @var string */ public $_field; /** * Constructor * @param string $name the name of the filter instance * @param string $label the label of the filter instance * @param boolean $advanced advanced form element flag * @param string $field user table filed name */ public function __construct($name, $label, $advanced, $field) { parent::__construct($name, $label, $advanced); $this->_field = $field; } /** * Old syntax of class constructor. Deprecated in PHP7. * * @deprecated since Moodle 3.1 */ public function user_filter_date($name, $label, $advanced, $field) { debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); self::__construct($name, $label, $advanced, $field); } /** * Adds controls specific to this filter in the form. * @param object $mform a MoodleForm object to setup */ public function setupForm(&$mform) { $objs = array(); $objs[] = $mform->createElement('static', $this->_name.'_s1', null, html_writer::start_tag('div', array('class' => 'w-100 d-flex align-items-center'))); $objs[] = $mform->createElement('static', $this->_name.'_s2', null, html_writer::tag('div', get_string('isafter', 'filters'), array('class' => 'me-2'))); $objs[] = $mform->createElement('date_selector', $this->_name.'_sdt', null, array('optional' => true)); $objs[] = $mform->createElement('static', $this->_name.'_s3', null, html_writer::end_tag('div')); $objs[] = $mform->createElement('static', $this->_name.'_s4', null, html_writer::start_tag('div', array('class' => 'w-100 d-flex align-items-center'))); $objs[] = $mform->createElement('static', $this->_name.'_s5', null, html_writer::tag('div', get_string('isbefore', 'filters'), array('class' => 'me-2'))); $objs[] = $mform->createElement('date_selector', $this->_name.'_edt', null, array('optional' => true)); $objs[] = $mform->createElement('static', $this->_name.'_s6', null, html_writer::end_tag('div')); $grp =& $mform->addElement('group', $this->_name.'_grp', $this->_label, $objs, '', false); if ($this->_advanced) { $mform->setAdvanced($this->_name.'_grp'); } } /** * Retrieves data from the form data * @param object $formdata data submited with the form * @return mixed array filter data or false when filter not set */ public function check_data($formdata) { $sdt = $this->_name.'_sdt'; $edt = $this->_name.'_edt'; if (!$formdata->$sdt and !$formdata->$edt) { return false; } $data = array(); $data['after'] = $formdata->$sdt; $data['before'] = $formdata->$edt; return $data; } /** * Returns the condition to be used with SQL where * @param array $data filter settings * @return array sql string and $params */ public function get_sql_filter($data) { $after = (int)$data['after']; $before = (int)$data['before']; $field = $this->_field; if (empty($after) and empty($before)) { return array('', array()); } $res = " $field >= 0 "; if ($after) { $res .= " AND $field >= $after"; } if ($before) { $res .= " AND $field <= $before"; } return array($res, array()); } /** * Returns a human friendly description of the filter used as label. * @param array $data filter settings * @return string active filter label */ public function get_label($data) { $after = $data['after']; $before = $data['before']; $field = $this->_field; $a = new stdClass(); $a->label = $this->_label; $a->after = userdate($after); $a->before = userdate($before); if ($after and $before) { return get_string('datelabelisbetween', 'filters', $a); } else if ($after) { return get_string('datelabelisafter', 'filters', $a); } else if ($before) { return get_string('datelabelisbefore', 'filters', $a); } return ''; } } home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/lib/classes/date.php000064400000114346152267632060022534 0ustar00. /** * Core date and time related code. * * @package core * @copyright 2015 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ /** * Core date and time related code. * * @since Moodle 2.9 * @package core * @copyright 2015 Totara Learning Solutions Ltd {@link http://www.totaralms.com/} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @author Petr Skoda */ class core_date { /** @var array list of recommended zones */ protected static $goodzones = null; /** @var array list of BC zones supported by PHP */ protected static $bczones = null; /** @var array mapping of timezones not supported by PHP */ protected static $badzones = null; /** @var string the default PHP timezone right after config.php */ protected static $defaultphptimezone = null; /** * Returns a localised list of timezones. * @param string $currentvalue * @param bool $include99 should the server timezone info be included? * @return array */ public static function get_list_of_timezones($currentvalue = null, $include99 = false) { self::init_zones(); // Localise first. $timezones = array(); foreach (self::$goodzones as $tzkey => $ignored) { $timezones[$tzkey] = self::get_localised_timezone($tzkey); } core_collator::asort($timezones); // Add '99' if requested. if ($include99 or $currentvalue == 99) { $timezones['99'] = self::get_localised_timezone('99'); } if (!isset($currentvalue) or isset($timezones[$currentvalue])) { return $timezones; } if (is_numeric($currentvalue)) { // UTC offset. if ($currentvalue == 0) { $a = 'UTC'; } else { $modifier = ($currentvalue > 0) ? '+' : ''; $a = 'UTC' . $modifier . number_format($currentvalue, 1); } $timezones[$currentvalue] = get_string('timezoneinvalid', 'core_admin', $a); } else { // Some string we don't recognise. $timezones[$currentvalue] = get_string('timezoneinvalid', 'core_admin', $currentvalue); } return $timezones; } /** * Returns localised timezone name. * @param string $tz * @return string */ public static function get_localised_timezone($tz) { if ($tz == 99) { $tz = self::get_server_timezone(); $tz = self::get_localised_timezone($tz); return get_string('timezoneserver', 'core_admin', $tz); } if (get_string_manager()->string_exists(strtolower($tz), 'core_timezones')) { $tz = get_string(strtolower($tz), 'core_timezones'); } else if ($tz === 'GMT' or $tz === 'Etc/GMT' or $tz === 'Etc/UTC') { $tz = 'UTC'; } else if (preg_match('|^Etc/GMT([+-])([0-9]+)$|', $tz, $matches)) { $sign = $matches[1] === '+' ? '-' : '+'; $tz = 'UTC' . $sign . $matches[2]; } return $tz; } /** * Normalise the timezone name. If timezone not supported * this method falls back to server timezone (if valid) * or default PHP timezone. * * @param int|string|float|DateTimeZone $tz * @return string timezone compatible with PHP */ public static function normalise_timezone($tz) { global $CFG; if ($tz instanceof DateTimeZone) { return $tz->getName(); } self::init_zones(); $tz = (string)$tz; if (isset(self::$goodzones[$tz]) or isset(self::$bczones[$tz])) { return $tz; } $fixed = false; if (isset(self::$badzones[$tz])) { // Convert to known zone. $tz = self::$badzones[$tz]; $fixed = true; } else if (is_numeric($tz)) { // Half hour numeric offsets were already tested, try rounding to integers here. $roundedtz = (string)(int)$tz; if (isset(self::$badzones[$roundedtz])) { $tz = self::$badzones[$roundedtz]; $fixed = true; } } if ($fixed and isset(self::$goodzones[$tz]) or isset(self::$bczones[$tz])) { return $tz; } // Is server timezone usable? if (isset($CFG->timezone) and !is_numeric($CFG->timezone)) { $result = timezone_open($CFG->timezone); // Hide notices if invalid. if ($result !== false) { return $result->getName(); } } // Bad luck, use the php.ini default or value set in config.php. return self::get_default_php_timezone(); } /** * Returns server timezone. * @return string normalised timezone name compatible with PHP **/ public static function get_server_timezone() { global $CFG; if (!isset($CFG->timezone) or $CFG->timezone == 99 or $CFG->timezone === '') { return self::get_default_php_timezone(); } return self::normalise_timezone($CFG->timezone); } /** * Returns server timezone. * @return DateTimeZone **/ public static function get_server_timezone_object() { $tz = self::get_server_timezone(); return new DateTimeZone($tz); } /** * Set PHP default timezone to $CFG->timezone. */ public static function set_default_server_timezone() { global $CFG; if (!isset($CFG->timezone) or $CFG->timezone == 99 or $CFG->timezone === '') { date_default_timezone_set(self::get_default_php_timezone()); return; } $current = date_default_timezone_get(); if ($current === $CFG->timezone) { // Nothing to do. return; } if (!isset(self::$goodzones)) { // For better performance try do do this without full tz init, // because this is called from lib/setup.php file on each page. $result = @timezone_open($CFG->timezone); // Ignore error if setting invalid. if ($result !== false) { date_default_timezone_set($result->getName()); return; } } // Slow way is the last option. date_default_timezone_set(self::get_server_timezone()); } /** * Returns user timezone. * * Ideally the parameter should be a real user record, * unfortunately the legacy code is using 99 for both server * and default value. * * Example of using legacy API: * // Date for other user via legacy API. * $datestr = userdate($time, core_date::get_user_timezone($user)); * * The coding style rules in Moodle are moronic, * why cannot the parameter names have underscores in them? * * @param mixed $userorforcedtz user object or legacy forced timezone string or tz object * @return string normalised timezone name compatible with PHP */ public static function get_user_timezone($userorforcedtz = null) { global $USER, $CFG; if ($userorforcedtz instanceof DateTimeZone) { return $userorforcedtz->getName(); } if (isset($userorforcedtz) and !is_object($userorforcedtz) and $userorforcedtz != 99) { // Legacy code is forcing timezone in legacy API. return self::normalise_timezone($userorforcedtz); } if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) { // Override any user timezone. return self::normalise_timezone($CFG->forcetimezone); } if ($userorforcedtz === null) { $tz = isset($USER->timezone) ? $USER->timezone : 99; } else if (is_object($userorforcedtz)) { $tz = isset($userorforcedtz->timezone) ? $userorforcedtz->timezone : 99; } else { if ($userorforcedtz == 99) { $tz = isset($USER->timezone) ? $USER->timezone : 99; } else { $tz = $userorforcedtz; } } if ($tz == 99) { return self::get_server_timezone(); } return self::normalise_timezone($tz); } /** * Return user timezone object. * * @param mixed $userorforcedtz * @return DateTimeZone */ public static function get_user_timezone_object($userorforcedtz = null) { $tz = self::get_user_timezone($userorforcedtz); return new DateTimeZone($tz); } /** * Return default timezone set in php.ini or config.php. * @return string normalised timezone compatible with PHP */ public static function get_default_php_timezone() { if (!isset(self::$defaultphptimezone)) { // This should not happen. self::store_default_php_timezone(); } return self::$defaultphptimezone; } /** * To be called from lib/setup.php only! */ public static function store_default_php_timezone() { if ((defined('PHPUNIT_TEST') and PHPUNIT_TEST) or defined('BEHAT_SITE_RUNNING') or defined('BEHAT_TEST') or defined('BEHAT_UTIL')) { // We want all test sites to be consistent by default. self::$defaultphptimezone = 'Australia/Perth'; return; } if (!isset(self::$defaultphptimezone)) { self::$defaultphptimezone = date_default_timezone_get(); } } /** * Do not use directly - use $this->setTimezone('xx', $tz) instead in your test case. * @param string $tz valid timezone name */ public static function phpunit_override_default_php_timezone($tz) { if (!defined('PHPUNIT_TEST')) { throw new coding_exception('core_date::phpunit_override_default_php_timezone() must be used only from unit tests'); } $result = @timezone_open($tz ?? ''); // This triggers error if $tz invalid. if ($result !== false) { self::$defaultphptimezone = $tz; } else { self::$defaultphptimezone = 'Australia/Perth'; } } /** * To be called from phpunit reset only, after restoring $CFG. */ public static function phpunit_reset() { global $CFG; if (!defined('PHPUNIT_TEST')) { throw new coding_exception('core_date::phpunit_reset() must be used only from unit tests'); } self::store_default_php_timezone(); date_default_timezone_set($CFG->timezone); } /** * Initialise timezone arrays, call before use. */ protected static function init_zones() { if (isset(self::$goodzones)) { return; } $zones = DateTimeZone::listIdentifiers(); self::$goodzones = array_fill_keys($zones, true); $zones = DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC); self::$bczones = array(); foreach ($zones as $zone) { if (isset(self::$goodzones[$zone])) { continue; } self::$bczones[$zone] = true; } self::$badzones = array( // Windows time zones. 'Dateline Standard Time' => 'Etc/GMT+12', 'Hawaiian Standard Time' => 'Pacific/Honolulu', 'Alaskan Standard Time' => 'America/Anchorage', 'Pacific Standard Time (Mexico)' => 'America/Tijuana', 'Pacific Standard Time' => 'America/Los_Angeles', 'US Mountain Standard Time' => 'America/Phoenix', 'Mountain Standard Time (Mexico)' => 'America/Chihuahua', 'Mountain Standard Time' => 'America/Denver', 'Central America Standard Time' => 'America/Guatemala', 'Central Standard Time' => 'America/Chicago', 'Central Standard Time (Mexico)' => 'America/Mexico_City', 'Canada Central Standard Time' => 'America/Regina', 'SA Pacific Standard Time' => 'America/Bogota', 'S.A. Pacific Standard Time' => 'America/Bogota', 'Eastern Standard Time' => 'America/New_York', 'US Eastern Standard Time' => 'America/Indiana/Indianapolis', 'U.S. Eastern Standard Time' => 'America/Indiana/Indianapolis', 'Venezuela Standard Time' => 'America/Caracas', 'Paraguay Standard Time' => 'America/Asuncion', 'Atlantic Standard Time' => 'America/Halifax', 'Central Brazilian Standard Time' => 'America/Cuiaba', 'SA Western Standard Time' => 'America/La_Paz', 'S.A. Western Standard Time' => 'America/La_Paz', 'Pacific SA Standard Time' => 'America/Santiago', 'Pacific S.A. Standard Time' => 'America/Santiago', 'Newfoundland Standard Time' => 'America/St_Johns', 'Newfoundland and Labrador Standard Time' => 'America/St_Johns', 'E. South America Standard Time' => 'America/Sao_Paulo', 'Argentina Standard Time' => 'America/Argentina/Buenos_Aires', 'SA Eastern Standard Time' => 'America/Cayenne', 'S.A. Eastern Standard Time' => 'America/Cayenne', 'Greenland Standard Time' => 'America/Godthab', 'Montevideo Standard Time' => 'America/Montevideo', 'Bahia Standard Time' => 'America/Bahia', 'Azores Standard Time' => 'Atlantic/Azores', 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde', 'Morocco Standard Time' => 'Africa/Casablanca', 'GMT Standard Time' => 'Europe/London', 'Greenwich Standard Time' => 'Atlantic/Reykjavik', 'W. Europe Standard Time' => 'Europe/Berlin', 'Central Europe Standard Time' => 'Europe/Budapest', 'Romance Standard Time' => 'Europe/Paris', 'Central European Standard Time' => 'Europe/Warsaw', 'W. Central Africa Standard Time' => 'Africa/Lagos', 'Namibia Standard Time' => 'Africa/Windhoek', 'Jordan Standard Time' => 'Asia/Amman', 'GTB Standard Time' => 'Europe/Bucharest', 'Middle East Standard Time' => 'Asia/Beirut', 'Egypt Standard Time' => 'Africa/Cairo', 'Syria Standard Time' => 'Asia/Damascus', 'South Africa Standard Time' => 'Africa/Johannesburg', 'FLE Standard Time' => 'Europe/Kiev', 'Turkey Standard Time' => 'Europe/Istanbul', 'Israel Standard Time' => 'Asia/Jerusalem', 'Kaliningrad Standard Time' => 'Europe/Kaliningrad', 'Libya Standard Time' => 'Africa/Tripoli', 'Arabic Standard Time' => 'Asia/Baghdad', 'Arab Standard Time' => 'Asia/Riyadh', 'Belarus Standard Time' => 'Europe/Minsk', 'Russian Standard Time' => 'Europe/Moscow', 'E. Africa Standard Time' => 'Africa/Nairobi', 'Iran Standard Time' => 'Asia/Tehran', 'Arabian Standard Time' => 'Asia/Dubai', 'Azerbaijan Standard Time' => 'Asia/Baku', 'Russia Time Zone 3' => 'Europe/Samara', 'Mauritius Standard Time' => 'Indian/Mauritius', 'Georgian Standard Time' => 'Asia/Tbilisi', 'Caucasus Standard Time' => 'Asia/Yerevan', 'Afghanistan Standard Time' => 'Asia/Kabul', 'West Asia Standard Time' => 'Asia/Tashkent', 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg', 'Pakistan Standard Time' => 'Asia/Karachi', 'India Standard Time' => 'Asia/Kolkata', // PHP and Windows differ in spelling. 'Sri Lanka Standard Time' => 'Asia/Colombo', 'Nepal Standard Time' => 'Asia/Kathmandu', 'Central Asia Standard Time' => 'Asia/Almaty', 'Bangladesh Standard Time' => 'Asia/Dhaka', 'N. Central Asia Standard Time' => 'Asia/Novosibirsk', 'Myanmar Standard Time' => 'Asia/Yangon', 'SE Asia Standard Time' => 'Asia/Bangkok', 'S.E. Asia Standard Time' => 'Asia/Bangkok', 'North Asia Standard Time' => 'Asia/Krasnoyarsk', 'China Standard Time' => 'Asia/Shanghai', 'North Asia East Standard Time' => 'Asia/Irkutsk', 'Singapore Standard Time' => 'Asia/Singapore', 'W. Australia Standard Time' => 'Australia/Perth', 'Taipei Standard Time' => 'Asia/Taipei', 'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar', 'Tokyo Standard Time' => 'Asia/Tokyo', 'Korea Standard Time' => 'Asia/Seoul', 'Yakutsk Standard Time' => 'Asia/Yakutsk', 'Cen. Australia Standard Time' => 'Australia/Adelaide', 'AUS Central Standard Time' => 'Australia/Darwin', 'A.U.S. Central Standard Time' => 'Australia/Darwin', 'E. Australia Standard Time' => 'Australia/Brisbane', 'AUS Eastern Standard Time' => 'Australia/Sydney', 'A.U.S. Eastern Standard Time' => 'Australia/Sydney', 'West Pacific Standard Time' => 'Pacific/Port_Moresby', 'Tasmania Standard Time' => 'Australia/Hobart', 'Magadan Standard Time' => 'Asia/Magadan', 'Vladivostok Standard Time' => 'Asia/Vladivostok', 'Russia Time Zone 10' => 'Asia/Srednekolymsk', 'Central Pacific Standard Time' => 'Pacific/Guadalcanal', 'Russia Time Zone 11' => 'Asia/Kamchatka', 'New Zealand Standard Time' => 'Pacific/Auckland', 'Fiji Standard Time' => 'Pacific/Fiji', 'Fiji Islands Standard Time' => 'Pacific/Fiji', 'Tonga Standard Time' => 'Pacific/Tongatapu', 'Samoa Standard Time' => 'Pacific/Apia', 'Line Islands Standard Time' => 'Pacific/Kiritimati', 'Mexico Standard Time 2' => 'America/Chihuahua', 'Mexico Standard Time' => 'America/Mexico_City', 'U.S. Mountain Standard Time' => 'America/Phoenix', 'Mid-Atlantic Standard Time' => 'Atlantic/South_Georgia', 'E. Europe Standard Time' => 'Europe/Minsk', 'Transitional Islamic State of Afghanistan Standard Time' => 'Asia/Kabul', 'Armenian Standard Time' => 'Asia/Yerevan', 'Kamchatka Standard Time' => 'Asia/Kamchatka', // A lot more bad legacy (deprecated) time zones. 'Australia/ACT' => 'Australia/Sydney', 'Australia/LHI' => 'Australia/Lord_Howe', 'Australia/North' => 'Australia/Darwin', 'Australia/NSW' => 'Australia/Sydney', 'Australia/Queensland' => 'Australia/Brisbane', 'Australia/South' => 'Australia/Adelaide', 'Australia/Tasmania' => 'Australia/Hobart', 'Australia/Victoria' => 'Australia/Melbourne', 'Australia/West' => 'Australia/Perth', 'Brazil/Acre' => 'America/Rio_Branco', 'Brazil/DeNoronha' => 'America/Noronha', 'Brazil/East' => 'America/Sao_Paulo', 'Brazil/West' => 'America/Manaus', 'Canada/Atlantic' => 'America/Halifax', 'Canada/Central' => 'America/Winnipeg', 'Canada/Eastern' => 'America/Toronto', 'Canada/Mountain' => 'America/Edmonton', 'Canada/Newfoundland' => 'America/St_Johns', 'Canada/Pacific' => 'America/Vancouver', 'Canada/Saskatchewan' => 'America/Regina', 'Canada/Yukon' => 'America/Whitehorse', 'CDT' => 'America/Chicago', 'CET' => 'Europe/Berlin', 'Central European Time' => 'Europe/Berlin', 'Central Time' => 'America/Chicago', 'Chile/Continental' => 'America/Santiago', 'Chile/EasterIsland' => 'Pacific/Easter', 'China Time' => 'Asia/Shanghai', 'CST' => 'America/Chicago', 'CST6CDT' => 'America/Chicago', 'Cuba' => 'America/Havana', 'EDT' => 'America/New_York', 'EET' => 'Europe/Kiev', 'Egypt' => 'Africa/Cairo', 'Eire' => 'Europe/Dublin', 'EST' => 'America/Cancun', 'EST5EDT' => 'America/New_York', 'Eastern Time' => 'America/New_York', 'Etc/Greenwich' => 'Etc/GMT', 'Etc/UCT' => 'Etc/UTC', 'Etc/Universal' => 'Etc/UTC', 'Etc/Zulu' => 'Etc/UTC', 'FET' => 'Europe/Minsk', 'GB' => 'Europe/London', 'GB-Eire' => 'Europe/London', 'Greenwich' => 'Etc/GMT', 'Hongkong' => 'Asia/Hong_Kong', 'HST' => 'Pacific/Honolulu', 'Iceland' => 'Atlantic/Reykjavik', 'India Time' => 'Asia/Kolkata', 'Iran' => 'Asia/Tehran', 'Israel' => 'Asia/Jerusalem', 'IST' => 'Asia/Kolkata', 'Jamaica' => 'America/Jamaica', 'Japan' => 'Asia/Tokyo', 'Japan Standard Time' => 'Asia/Tokyo', 'Japan Time' => 'Asia/Tokyo', 'JST' => 'Asia/Tokyo', 'Kwajalein' => 'Pacific/Kwajalein', 'Libya' => 'Africa/Tripoli', 'MDT' => 'America/Denver', 'MET' => 'Europe/Paris', 'Mexico/BajaNorte' => 'America/Tijuana', 'Mexico/BajaSur' => 'America/Mazatlan', 'Mexico/General' => 'America/Mexico_City', 'MST' => 'America/Phoenix', 'MST7MDT' => 'America/Denver', 'Navajo' => 'America/Denver', 'NZ' => 'Pacific/Auckland', 'NZ-CHAT' => 'Pacific/Chatham', 'Pacific Time' => 'America/Los_Angeles', 'PDT' => 'America/Los_Angeles', 'Poland' => 'Europe/Warsaw', 'Portugal' => 'Europe/Lisbon', 'PRC' => 'Asia/Shanghai', 'PST' => 'America/Los_Angeles', 'PST8PDT' => 'America/Los_Angeles', 'ROC' => 'Asia/Taipei', 'ROK' => 'Asia/Seoul', 'Singapore' => 'Asia/Singapore', 'Turkey' => 'Europe/Istanbul', 'UCT' => 'Etc/UTC', 'Universal' => 'Etc/UTC', 'US/Alaska' => 'America/Anchorage', 'US/Aleutian' => 'America/Adak', 'US/Arizona' => 'America/Phoenix', 'US/Central' => 'America/Chicago', 'US/East-Indiana' => 'America/Indiana/Indianapolis', 'US/Eastern' => 'America/New_York', 'US/Hawaii' => 'Pacific/Honolulu', 'US/Indiana-Starke' => 'America/Indiana/Knox', 'US/Michigan' => 'America/Detroit', 'US/Mountain' => 'America/Denver', 'US/Pacific' => 'America/Los_Angeles', 'US/Pacific-New' => 'America/Los_Angeles', 'US/Samoa' => 'Pacific/Pago_Pago', 'W-SU' => 'Europe/Moscow', 'WET' => 'Europe/London', 'Zulu' => 'Etc/UTC', // Some UTC variations. 'UTC-01' => 'Etc/GMT+1', 'UTC-02' => 'Etc/GMT+2', 'UTC-03' => 'Etc/GMT+3', 'UTC-04' => 'Etc/GMT+4', 'UTC-05' => 'Etc/GMT+5', 'UTC-06' => 'Etc/GMT+6', 'UTC-07' => 'Etc/GMT+7', 'UTC-08' => 'Etc/GMT+8', 'UTC-09' => 'Etc/GMT+9', // Some weird GMTs. 'Etc/GMT+0' => 'Etc/GMT', 'Etc/GMT-0' => 'Etc/GMT', 'Etc/GMT0' => 'Etc/GMT', // Link old timezone names with their new names. 'Africa/Asmera' => 'Africa/Asmara', 'Africa/Timbuktu' => 'Africa/Abidjan', 'America/Argentina/ComodRivadavia' => 'America/Argentina/Catamarca', 'America/Atka' => 'America/Adak', 'America/Buenos_Aires' => 'America/Argentina/Buenos_Aires', 'America/Catamarca' => 'America/Argentina/Catamarca', 'America/Coral_Harbour' => 'America/Atikokan', 'America/Cordoba' => 'America/Argentina/Cordoba', 'America/Ensenada' => 'America/Tijuana', 'America/Fort_Wayne' => 'America/Indiana/Indianapolis', 'America/Godthab' => 'America/Nuuk', 'America/Indianapolis' => 'America/Indiana/Indianapolis', 'America/Jujuy' => 'America/Argentina/Jujuy', 'America/Knox_IN' => 'America/Indiana/Knox', 'America/Louisville' => 'America/Kentucky/Louisville', 'America/Mendoza' => 'America/Argentina/Mendoza', 'America/Montreal' => 'America/Toronto', 'America/Porto_Acre' => 'America/Rio_Branco', 'America/Rosario' => 'America/Argentina/Cordoba', 'America/Santa_Isabel' => 'America/Tijuana', 'America/Shiprock' => 'America/Denver', 'America/Virgin' => 'America/Port_of_Spain', 'Antarctica/South_Pole' => 'Pacific/Auckland', 'Asia/Ashkhabad' => 'Asia/Ashgabat', 'Asia/Calcutta' => 'Asia/Kolkata', 'Asia/Chongqing' => 'Asia/Shanghai', 'Asia/Chungking' => 'Asia/Shanghai', 'Asia/Dacca' => 'Asia/Dhaka', 'Asia/Harbin' => 'Asia/Shanghai', 'Asia/Istanbul' => 'Europe/Istanbul', 'Asia/Kashgar' => 'Asia/Urumqi', 'Asia/Katmandu' => 'Asia/Kathmandu', 'Asia/Macao' => 'Asia/Macau', 'Asia/Rangoon' => 'Asia/Yangon', 'Asia/Saigon' => 'Asia/Ho_Chi_Minh', 'Asia/Tel_Aviv' => 'Asia/Jerusalem', 'Asia/Thimbu' => 'Asia/Thimphu', 'Asia/Ujung_Pandang' => 'Asia/Makassar', 'Asia/Ulan_Bator' => 'Asia/Ulaanbaatar', 'Atlantic/Faeroe' => 'Atlantic/Faroe', 'Atlantic/Jan_Mayen' => 'Europe/Oslo', 'Australia/Canberra' => 'Australia/Sydney', 'Australia/Yancowinna' => 'Australia/Broken_Hill', 'Europe/Belfast' => 'Europe/London', 'Europe/Kiev' => 'Europe/Kyiv', 'Europe/Nicosia' => 'Asia/Nicosia', 'Europe/Tiraspol' => 'Europe/Chisinau', 'Pacific/Enderbury' => 'Pacific/Kanton', 'Pacific/Johnston' => 'Pacific/Honolulu', 'Pacific/Ponape' => 'Pacific/Pohnpei', 'Pacific/Samoa' => 'Pacific/Pago_Pago', 'Pacific/Truk' => 'Pacific/Chuuk', 'Pacific/Yap' => 'Pacific/Chuuk', ); // Legacy GMT fallback. for ($i = -12; $i <= 14; $i++) { $off = abs($i); if ($i < 0) { $mapto = 'Etc/GMT+' . $off; $utc = 'UTC-' . $off; $gmt = 'GMT-' . $off; } else if ($i > 0) { $mapto = 'Etc/GMT-' . $off; $utc = 'UTC+' . $off; $gmt = 'GMT+' . $off; } else { $mapto = 'Etc/GMT'; $utc = 'UTC'; $gmt = 'GMT'; } if (isset(self::$bczones[$mapto])) { self::$badzones[$i . ''] = $mapto; self::$badzones[$i . '.0'] = $mapto; self::$badzones[$utc] = $mapto; self::$badzones[$gmt] = $mapto; } } // Legacy Moodle half an hour offsets - pick any city nearby, ideally without DST. self::$badzones['4.5'] = 'Asia/Kabul'; self::$badzones['5.5'] = 'Asia/Kolkata'; self::$badzones['6.5'] = 'Asia/Rangoon'; self::$badzones['9.5'] = 'Australia/Darwin'; // Remove bad zones that are elsewhere. foreach (self::$bczones as $zone => $unused) { if (isset(self::$badzones[$zone])) { unset(self::$badzones[$zone]); } } foreach (self::$goodzones as $zone => $unused) { if (isset(self::$badzones[$zone])) { unset(self::$badzones[$zone]); } } } /** * Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible) * This provides a cross-platform alternative to strftime() for when it will be removed from PHP. * Note that output can be slightly different between libc sprintf and this function as it is using ICU. * * From: * https://github.com/alphp/strftime * * @param string $format Date format * @param int|string|DateTime $timestamp Timestamp * @param string|null $locale * @return string * @author BohwaZ */ public static function strftime(string $format, $timestamp = null, ?string $locale = null): string { // Moodle-specific modification. For the IntlDateFormatter we need to use unix-style locale // from the string 'locale' even for Windows, so we can neither use moodle_getlocale(). // nor rely on the setlocale() use below. We also ignore $CFG->locale because it can use // Windows format. $locale = $locale ?: get_string('locale', 'langconfig'); // The following code is taken from https://github.com/alphp/strftime. // phpcs:disable if (!($timestamp instanceof DateTimeInterface)) { $timestamp = is_numeric($timestamp) ? '@' . $timestamp : (string) $timestamp; try { $timestamp = new DateTime($timestamp); } catch (Exception $e) { throw new InvalidArgumentException('$timestamp argument is neither a valid UNIX timestamp, a valid date-time string or a DateTime object.', 0, $e); } } $timestamp->setTimezone(new DateTimeZone(date_default_timezone_get())); if (empty($locale)) { // get current locale $locale = setlocale(LC_TIME, '0'); } // remove trailing part not supported by ext-intl locale $locale = preg_replace('/[^\w-].*$/', '', $locale); $intl_formats = [ '%a' => 'EEE', // An abbreviated textual representation of the day Sun through Sat '%A' => 'EEEE', // A full textual representation of the day Sunday through Saturday ]; $originalformat = $format; $intl_formatter = function (DateTimeInterface $timestamp, string $format) use ( $intl_formats, $locale, $originalformat, ) { // Map IANA timezone DB names (used by PHP) to those used internally by the "intl" extension. The extension uses its // own data based on ICU timezones, which may not necessarily be in-sync with IANA depending on the version installed // on the local system. See: https://unicode-org.github.io/icu/userguide/datetime/timezone/#updating-the-time-zone-data $tz = $timestamp->getTimezone(); $intltz = IntlTimeZone::fromDateTimeZone($tz); if ($intltz === null) { // Where intl doesn't know about a recent timezone, map it to an equivalent existing zone. $intltzname = strtr($tz->getName(), [ 'America/Coyhaique' => 'America/Santiago', 'America/Ciudad_Juarez' => 'America/Denver', 'America/Nuuk' => 'America/Godthab', 'Europe/Kyiv' => 'Europe/Kiev', 'Pacific/Kanton' => 'Pacific/Enderbury', ]); $intltz = IntlTimeZone::createTimeZone($intltzname); } $date_type = IntlDateFormatter::FULL; $time_type = IntlDateFormatter::FULL; $pattern = ''; switch ($format) { // %c = Preferred date and time stamp based on locale // Example: Tue Feb 5 00:45:10 2009 for February 5, 2009 at 12:45:10 AM case '%c': $date_type = IntlDateFormatter::LONG; $time_type = IntlDateFormatter::SHORT; break; // %x = Preferred date representation based on locale, without the time // Example: 02/05/09 for February 5, 2009 case '%x': $date_type = IntlDateFormatter::SHORT; $time_type = IntlDateFormatter::NONE; break; // Localized time format case '%X': $date_type = IntlDateFormatter::NONE; $time_type = IntlDateFormatter::MEDIUM; break; case "%B": case "%b": case "%h": // Check for any day (%d, or %e) in the string. if (preg_match('/%[de]/', $originalformat)) { // The day is present so use the standard format. $pattern = $format === '%B' ? 'MMMM' : 'MMM'; } else { // The day is not present so use the stand-alone format. $pattern = $format === '%B' ? 'LLLL' : 'LLL'; } break; default: $pattern = $intl_formats[$format]; } // In October 1582, the Gregorian calendar replaced the Julian in much of Europe, and // the 4th October was followed by the 15th October. // ICU (including IntlDateFormattter) interprets and formats dates based on this cutover. // Posix (including strftime) and timelib (including DateTimeImmutable) instead use // a "proleptic Gregorian calendar" - they pretend the Gregorian calendar has existed forever. // This leads to the same instants in time, as expressed in Unix time, having different representations // in formatted strings. // To adjust for this, a custom calendar can be supplied with a cutover date arbitrarily far in the past. $calendar = IntlGregorianCalendar::createInstance($intltz); $calendar->setGregorianChange(PHP_INT_MIN); // We need to account for invalid locales here in recent PHP versions, and ensure we catch errors and switch // back to a default value where an invalid locale is provided. try { $formatter = new IntlDateFormatter($locale, $date_type, $time_type, $intltz, $calendar, $pattern); $result = $formatter->format($timestamp); } catch (Error $e) { $formatter = new IntlDateFormatter(null, $date_type, $time_type, $intltz, $calendar, $pattern); $result = $formatter->format($timestamp); } return $result; }; // Same order as https://www.php.net/manual/en/function.strftime.php $translation_table = [ // Day '%a' => $intl_formatter, '%A' => $intl_formatter, '%d' => 'd', '%e' => function ($timestamp) { return sprintf('% 2u', $timestamp->format('j')); }, '%j' => function ($timestamp) { // Day number in year, 001 to 366 return sprintf('%03d', $timestamp->format('z')+1); }, '%u' => 'N', '%w' => 'w', // Week '%U' => function ($timestamp) { // Number of weeks between date and first Sunday of year $day = new DateTime(sprintf('%d-01 Sunday', $timestamp->format('Y'))); return sprintf('%02u', 1 + ($timestamp->format('z') - $day->format('z')) / 7); }, '%V' => 'W', '%W' => function ($timestamp) { // Number of weeks between date and first Monday of year $day = new DateTime(sprintf('%d-01 Monday', $timestamp->format('Y'))); return sprintf('%02u', 1 + ($timestamp->format('z') - $day->format('z')) / 7); }, // Month '%b' => $intl_formatter, '%B' => $intl_formatter, '%h' => $intl_formatter, '%m' => 'm', // Year '%C' => function ($timestamp) { // Century (-1): 19 for 20th century return floor($timestamp->format('Y') / 100); }, '%g' => function ($timestamp) { return substr($timestamp->format('o'), -2); }, '%G' => 'o', '%y' => 'y', '%Y' => 'Y', // Time '%H' => 'H', '%k' => function ($timestamp) { return sprintf('% 2u', $timestamp->format('G')); }, '%I' => 'h', '%l' => function ($timestamp) { return sprintf('% 2u', $timestamp->format('g')); }, '%M' => 'i', '%p' => 'A', // AM PM (this is reversed on purpose!) '%P' => 'a', // am pm '%r' => 'h:i:s A', // %I:%M:%S %p '%R' => 'H:i', // %H:%M '%S' => 's', '%T' => 'H:i:s', // %H:%M:%S '%X' => $intl_formatter, // Preferred time representation based on locale, without the date // Timezone '%z' => 'O', '%Z' => 'T', // Time and Date Stamps '%c' => $intl_formatter, '%D' => 'm/d/Y', '%F' => 'Y-m-d', '%s' => 'U', '%x' => $intl_formatter, ]; $out = preg_replace_callback('/(?format($replace); } else { $result = $replace($timestamp, $pattern); } switch ($prefix) { case '_': // replace leading zeros with spaces but keep last char if also zero return preg_replace('/\G0(?=.)/', ' ', $result); case '#': case '-': // remove leading zeros but keep last char if also zero return preg_replace('/^0+(?=.)/', '', $result); } return $result; }, $format); $out = str_replace('%%', '%', $out); return $out; // phpcs:enable } }