API / Minn\Support / TimezoneChoice

TimezoneChoice final class

Minn\Support\TimezoneChoice · public/minn/src/Minn/Support/TimezoneChoice.php · 109 lines

The timezone choices a settings form offers (wp_timezone_choice, probe placeholder-helpers): the zones of each continent, cities in natural order (a zone with three parts reads "City - Sub-city"), then UTC, then the offsets set by hand. "Select a city" leads when nothing is chosen, and a real zone outside the list (an old name, Etc/) leads when it is the one chosen. Each choice is a line of its own.

Uses 1

Constants and properties

privateCONTINENTS = array ( 0 => 'Africa', 1 => 'America', 2 => 'Antarctica', 3 => 'Arctic', 4 => 'Asia', 5 => 'Atlantic', 6 => 'Australia', 7 => 'Europe', 8 => 'Indian', 9 => 'Pacific', )

Public

statichtml(string $selected, Closure $translate): string#

The choices as option lines, the chosen zone marked.

$translate\Closure(string, string): stringa text in a text domain, translated

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatezones(Closure $translate): array#

The continents' zones in order: continent, city, then sub-city, each compared naturally and without case.

@return list<array{value: string, continent: string, city: string, sub: string, label: string}>
privategroups(array $zones): array#
$zoneslist<array{value: string, continent: string, city: string, sub: string, label: string}>
@return array<string, list<array{value: string, continent: string, city: string, sub: string, label: string}>>
privateoutsideList(string $selected, array $listed): bool#

Whether a chosen zone is a real one the list leaves out (not UTC, not an offset). @param list<string> $listed

$listedlist<string>
privateoffset(int|float $offset): array#

An offset's value (UTC+5.75) and label (UTC+5:45). @return array{0: string, 1: string}

@return array{0: string, 1: string}
privateoffsets(): array#

The offsets offered by hand, in hours, lowest first: every half hour from -12 to +12, the three-quarter hours some zones keep, and the hours past +12 up to +14.

@return list<float|int>
privateoption(string $value, string $label, string $chosen): string#

One choice, marked when it is the chosen zone.