TappNetwork / filament-timezone-field

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ enhancement ] - Multiple Countries

flashmediasolutions opened this issue · comments

Not familiar with creating PR's. I wanted the ability to supply more than one country to get timezones from, so I implemented this customization. Could it possibly get added to master?

trait HasTimezoneOptions

protected array | string | Closure | null $byCountry = null;

public function byCountry(array | Closure | null $countryCodes): static
    {
        $this->byCountry = $countryCodes;

        return $this;
    }

protected function listTimezonesByCountry(array | string $countryCodes)
    {
        if (is_string($countryCodes)) {
            $countryCodes = [$countryCodes];
        }

        $timezones = [];
        foreach ($countryCodes as $countryCode) {
            $timezones = array_merge($timezones, DateTimeZone::listIdentifiers(
                timezoneGroup: DateTimeZone::PER_COUNTRY,
                countryCode: $countryCode,
            ));
        }

        return $timezones;
    }

@flashmediasolutions Thank you for this suggestion! :)
Created a PR #13 and added you as an author on commit ❤️