gsteel / google-timezone
Google Timezone API Client
Installs: 11 202
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 3
Requires
- php: ~8.1 || ~8.2 || ~8.3 || ~8.4
- fig/http-message-util: ^1.1
- psr/http-client: ^1.0
- psr/http-client-implementation: *
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
Requires (Dev)
- ext-curl: *
- doctrine/coding-standard: ^12.0.0
- ergebnis/composer-normalize: ^2.44.0
- infection/infection: ^0.27.11
- laminas/laminas-diactoros: ^3.5.0
- php-http/curl-client: ^2.3.2
- php-http/discovery: ^1.20.0
- phpunit/phpunit: ^10.5.37
- psalm/plugin-phpunit: ^0.19.0
- react/child-process: ^0.6.5
- react/http: ^1.10.0
- roave/security-advisories: dev-latest
- vimeo/psalm: ^5.26.1
README
Introduction
Provides a well tested set of interfaces and value objects for interacting with Google's Timezone API
Installation
The only supported method of installation is via composer.
This client requires a PSR-18 Http Client and PSR-17 Factory implementations. These implementations are not required by composer, so you will need to ensure you have them installed, for example,
composer require php-http/curl-client laminas/laminas-diactoros gsteel/google-timezone
Usage
The TimeZone API requires an API key from Google
<?php use DateTimeImmutable; use GSteel\GoogleTimezone\Coordinates; use GSteel\GoogleTimezone\HttpClient; use Http\Client\Curl\Client; use Laminas\Diactoros\RequestFactory; use Laminas\Diactoros\UriFactory; $apiKey = 'Some API Key'; $client = new HttpClient( $apiKey, new Client(), new UriFactory(), new RequestFactory() ); $primeMeridian = '51.47,-0.00'; $referenceDate = DateTimeImmutable::createFromFormat('!Y-m-d', '2020-01-01'); $result = $this->client->fetch( Coordinates::fromString($primeMeridian), $referenceDate ); assert($result->isSuccess()); // true echo $result->timezone()->getName(); // "Europe/London" $result->isReferenceDateDst(); // false echo $result->name(); // "Greenwich Mean Time"
License
Contributing
…is welcomed. Please make sure your patch passes CI :)