ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Shared\TimeZone Class Reference
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Shared\TimeZone:

Static Public Member Functions

static setTimeZone ($timezone)
 Set the Default Timezone used for date/time conversions. More...
 
static getTimeZone ()
 Return the Default Timezone used for date/time conversions. More...
 
static getTimeZoneAdjustment ($timezone, $timestamp)
 Return the Timezone offset used for date/time conversions to/from UST This requires both the timezone and the calculated date/time to allow for local DST. More...
 

Static Protected Attributes

static $timezone = 'UTC'
 

Static Private Member Functions

static validateTimeZone ($timezone)
 Validate a Timezone name. More...
 

Detailed Description

Definition at line 8 of file TimeZone.php.

Member Function Documentation

◆ getTimeZone()

static PhpOffice\PhpSpreadsheet\Shared\TimeZone::getTimeZone ( )
static

Return the Default Timezone used for date/time conversions.

Returns
string Timezone (e.g. 'Europe/London')

Definition at line 52 of file TimeZone.php.

53  {
54  return self::$timezone;
55  }

◆ getTimeZoneAdjustment()

static PhpOffice\PhpSpreadsheet\Shared\TimeZone::getTimeZoneAdjustment (   $timezone,
  $timestamp 
)
static

Return the Timezone offset used for date/time conversions to/from UST This requires both the timezone and the calculated date/time to allow for local DST.

Parameters
?string$timezone The timezone for finding the adjustment to UST
float | int$timestampPHP date/time value
Returns
int Number of seconds for timezone adjustment

Definition at line 66 of file TimeZone.php.

References PhpOffice\PhpSpreadsheet\Shared\TimeZone\$timezone.

67  {
68  $timezone = $timezone ?? self::$timezone;
69  $dtobj = Date::dateTimeFromTimestamp("$timestamp");
70  if (!self::validateTimezone($timezone)) {
71  throw new PhpSpreadsheetException("Invalid timezone $timezone");
72  }
73  $dtobj->setTimeZone(new DateTimeZone($timezone));
74 
75  return $dtobj->getOffset();
76  }

◆ setTimeZone()

static PhpOffice\PhpSpreadsheet\Shared\TimeZone::setTimeZone (   $timezone)
static

Set the Default Timezone used for date/time conversions.

Parameters
string$timezoneTime zone (e.g. 'Europe/London')
Returns
bool Success or failure

Definition at line 36 of file TimeZone.php.

References PhpOffice\PhpSpreadsheet\Shared\TimeZone\$timezone.

37  {
38  if (self::validateTimezone($timezone)) {
39  self::$timezone = $timezone;
40 
41  return true;
42  }
43 
44  return false;
45  }

◆ validateTimeZone()

static PhpOffice\PhpSpreadsheet\Shared\TimeZone::validateTimeZone (   $timezone)
staticprivate

Validate a Timezone name.

Parameters
string$timezoneTime zone (e.g. 'Europe/London')
Returns
bool Success or failure

Definition at line 24 of file TimeZone.php.

References PhpOffice\PhpSpreadsheet\Shared\TimeZone\$timezone.

25  {
26  return in_array($timezone, DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC));
27  }

Field Documentation

◆ $timezone

PhpOffice\PhpSpreadsheet\Shared\TimeZone::$timezone = 'UTC'
staticprotected

The documentation for this class was generated from the following file: