Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 2.38 KB

File metadata and controls

92 lines (66 loc) · 2.38 KB

Time Zone

The Google Maps Time Zone API provides a simple interface to request the time zone for a location on the earth, as well as that location's time offset from UTC.

Dependencies

The Time Zone API requires an http client and a serializer. The library relies respectively on Httplug which is an http client abstraction library and the Ivory Serializer which is an advanced (de)-serialization library.

To install them, read this documentation.

Configuration

By default, the time zone service is disabled. In order to enable the service, you need to configure it.

Http client and message factory

The http client and message factory are mandatory. They define which http client and message factory the time zone service will use for issuing http requests.

First, configure the Httplug bundle.

httplug:
    classes:
        client: Http\Adapter\Guzzle7\Client
        message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
    clients:
        acme:
            factory: httplug.factory.guzzle7

Then, configure the Google Map bundle:

ivory_google_map:
    time_zone:
        client: httplug.client.default
        message_factory: httplug.message_factory.default

Format

The format allows you to use json/xml format for your http request:

ivory_google_map:
    time_zone:
        format: json

Api key

The API key allows you to bypass Google limitation according to your account plan:

ivory_google_map:
    time_zone:
        api_key: ~

Business account

The business account allows you to use Google Premium account:

ivory_google_map:
    time_zone:
        business_account:
            client_id: ~
            secret: ~
            channel: ~

Usage

Once you have configured your time zone service, you can fetch it from the container and use it as explained in the documentation

use Ivory\GoogleMap\Base\Coordinate;
use Ivory\GoogleMap\Service\TimeZone\TimeZoneRequest;

$request = new TimeZoneRequest(
   new Coordinate(39.6034810, -119.6822510),
   new \DateTime('@1331161200')
);

$response = $this->container->get('ivory.google_map.time_zone')->process($request);