diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 3c49b562f..7b7bd3d8c 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -362,3 +362,26 @@ form: 0: No validate: type: bool + system: + type: section + title: System + underline: true + + fields: + timezone: + type: select + label: Timezone + classes: fancy + @data-options: '\Grav\Common\Utils::timezones' + default: '' + options: + '': '- None -' + + param_sep: + type: select + label: Parameter separator + classes: fancy + default: '' + options: + ':': ': (default)' + ';': '; (use this for apache on Windows)' diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 97e4d6b52..ac1a2dcec 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -348,4 +348,32 @@ abstract class Utils } return $root . implode('/', $ret); } + + public static function timezones() + { + $timezones = \DateTimeZone::listIdentifiers(\DateTimeZone::ALL); + $offsets = []; + $testDate = new \DateTime; + + foreach ($timezones as $zone) { + $tz = new \DateTimeZone($zone); + $offsets[$zone] = $tz->getOffset($testDate); + } + + asort($offsets); + + $timezone_list = array(); + foreach( $offsets as $timezone => $offset ) + { + $offset_prefix = $offset < 0 ? '-' : '+'; + $offset_formatted = gmdate( 'H:i', abs($offset) ); + + $pretty_offset = "UTC${offset_prefix}${offset_formatted}"; + + $timezone_list[$timezone] = "(${pretty_offset}) $timezone"; + } + + return $timezone_list; + + } }