TimeZoneService
in package
A class service for working with the logic business of time zones.
Tags
Table of Contents
- $timeZoneRepository : TimeZoneRepository
- __construct() : mixed
- TimeZoneService constructor.
- findByZoneName() : TimeZoneDomain|null
- Find a time zone by zone name and time. If the time is not provided, the current time is used.
- getDateInTimeZone() : DateTime
- Get the date in determined time zone.
- getDateTimeInTimeZone() : DateTime
- Convert a time in UTC to a time in the time zone.
- getDayOfWeek() : string
- Extract the day of the week in determined time zone.
- getOffsetString() : string
- Get the offset string for a time zone in the format "+HH:MM" or "-HH:MM".
- mapEntityToDomain() : TimeZoneDomain
- Transform a time zone entity to a time zone domain.
Properties
$timeZoneRepository
private
TimeZoneRepository
$timeZoneRepository
The time zone repository.
Methods
__construct()
TimeZoneService constructor.
public
__construct(TimeZoneRepository $timeZoneRepository) : mixed
Parameters
- $timeZoneRepository : TimeZoneRepository
-
The time zone repository.
Return values
mixed —findByZoneName()
Find a time zone by zone name and time. If the time is not provided, the current time is used.
public
findByZoneName(string $getZoneName[, int|null $time = null ]) : TimeZoneDomain|null
Parameters
- $getZoneName : string
- $time : int|null = null
Tags
Return values
TimeZoneDomain|null —getDateInTimeZone()
Get the date in determined time zone.
public
getDateInTimeZone(int $time, TimeZoneDomain $timeZoneDomain) : DateTime
Parameters
- $time : int
-
The time in UTC.
- $timeZoneDomain : TimeZoneDomain
-
The time zone to convert to.
Tags
Return values
DateTime —getDateTimeInTimeZone()
Convert a time in UTC to a time in the time zone.
public
getDateTimeInTimeZone(int $time, TimeZoneDomain $timeZoneDomain) : DateTime
Parameters
- $time : int
-
The time in UTC.
- $timeZoneDomain : TimeZoneDomain
-
The time zone to convert to.
Tags
Return values
DateTime —getDayOfWeek()
Extract the day of the week in determined time zone.
public
getDayOfWeek(int $time, TimeZoneDomain $timeZoneDomain) : string
Parameters
- $time : int
-
The time in UTC.
- $timeZoneDomain : TimeZoneDomain
-
The time zone to convert to.
Tags
Return values
string —getOffsetString()
Get the offset string for a time zone in the format "+HH:MM" or "-HH:MM".
public
getOffsetString(TimeZoneDomain $timeZoneDomain) : string
Parameters
- $timeZoneDomain : TimeZoneDomain
-
The time zone to get the offset string for.
Return values
string —The offset string.
mapEntityToDomain()
Transform a time zone entity to a time zone domain.
private
static mapEntityToDomain(TimeZoneEntity $timeZoneEntity) : TimeZoneDomain
Parameters
- $timeZoneEntity : TimeZoneEntity
-
The time zone entity to transform.
Return values
TimeZoneDomain —The new time zone domain.