Medical Appointments API

TimeZoneService
in package

A class service for working with the logic business of time zones.

Tags
author

Luis Graciano contacto@luisgraciano.dev

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

Methods

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
throws
UnhandledException

If an error occurs while finding the time zone.

throws
NotFoundException

If the time zone is not found.

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
throws
Exception

If an error occurs while converting the time.

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
throws
Exception

If an error occurs while converting the time.

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
throws
Exception

If an error occurs while converting the time.

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.

Search results