You are here

public function Timezone::__construct in Geo Time Zone 8.3

Same name and namespace in other branches
  1. 8 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()
  2. 8.2 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()
  3. 6.2 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()
  4. 6 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()
  5. 7.2 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()
  6. 7 src/Timezone.php \Drupal\geotimezone\Timezone::__construct()

Timezone constructor.

Parameters

int $index: Time zone list index.

File

src/Timezone.php, line 43
Contains \Drupal\geotimezone\Timezone.

Class

Timezone
Holds the list of time zone identifiers and UTC/GMT offsets.

Namespace

Drupal\geotimezone

Code

public function __construct($index = 0) {
  static::$list = $this
    ->loadList();
  $this->identifier = static::$list[$index]['identifier'];

  // Convert to time zone offset
  $time = new \DateTime('now', new \DateTimeZone($this->identifier));
  $this->offset = $time
    ->format('P');

  //$this->offset = static::$list[$index]['offset'];
}