CarbonTimeZone
extends DateTimeZone
in package
Uses
LocalFactory
Table of Contents
Constants
Properties
- $clock : WrapperClock|null
- The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)
Methods
- __construct() : mixed
- __toString() : string
- Cast to string (get timezone name).
- cast() : DateTimeZone|mixed
- Cast the current instance into the given class.
- create() : false|static
- Create a CarbonTimeZone from mixed input.
- createFromHourOffset() : false|static
- Create a CarbonTimeZone from int/float hour offset.
- createFromMinuteOffset() : false|static
- Create a CarbonTimeZone from int/float minute offset.
- getAbbr() : string
- getAbbreviatedName() : string
- Returns abbreviated name of the current timezone according to DST setting.
- getClock() : WrapperClock|null
- getOffsetNameFromMinuteOffset() : string
- Convert a total minutes offset into a standardized timezone offset string.
- getType() : int
- Return the type number:
- instance() : static|null
- Create a CarbonTimeZone from mixed input.
- toOffsetName() : string
- Get the offset as string "sHH:MM" (such as "+00:00" or "-12:30").
- toOffsetTimeZone() : static
- Returns a new CarbonTimeZone object using the offset string instead of region string.
- toRegionName() : string|null
- Returns the first region string (such as "America/Toronto") that matches the current timezone or false if no match is found.
- toRegionTimeZone() : self|null
- Returns a new CarbonTimeZone object using the region string instead of offset string.
- getDateTimeZoneNameFromMixed() : string
- parseNumericTimezone() : string
- getFactory() : Factory
- initLocalFactory() : void
- resolveCarbon() : DateTimeInterface
- transmitFactory() : T
- Trigger the given action using the local factory of the object, so it will be transmitted to any object also using this trait and calling initLocalFactory() in its constructor.
Constants
MAXIMUM_TIMEZONE_OFFSET
public
mixed
MAXIMUM_TIMEZONE_OFFSET
= 99
Properties
$clock
The clock that generated the current instance (or FactoryImmutable::getDefaultInstance() if none)
private
WrapperClock|null
$clock
= null
Methods
__construct()
public
__construct(string|int|float $timezone) : mixed
Parameters
- $timezone : string|int|float
__toString()
Cast to string (get timezone name).
public
__toString() : string
Return values
stringcast()
Cast the current instance into the given class.
public
cast(DateTimeZone> $className) : DateTimeZone|mixed
Parameters
- $className : DateTimeZone>
-
The $className::instance() method will be called to cast the current object.
Return values
DateTimeZone|mixedcreate()
Create a CarbonTimeZone from mixed input.
public
static create([DateTimeZone|string|int|null $object = null ]) : false|static
Parameters
- $object : DateTimeZone|string|int|null = null
Return values
false|staticcreateFromHourOffset()
Create a CarbonTimeZone from int/float hour offset.
public
static createFromHourOffset(float $hourOffset) : false|static
Parameters
- $hourOffset : float
-
number of hour of the timezone shift (can be decimal).
Return values
false|staticcreateFromMinuteOffset()
Create a CarbonTimeZone from int/float minute offset.
public
static createFromMinuteOffset(float $minuteOffset) : false|static
Parameters
- $minuteOffset : float
-
number of total minutes of the timezone shift.
Return values
false|staticgetAbbr()
public
getAbbr([bool $dst = false ]) : string
Parameters
- $dst : bool = false
Tags
Return values
stringgetAbbreviatedName()
Returns abbreviated name of the current timezone according to DST setting.
public
getAbbreviatedName([bool $dst = false ]) : string
Parameters
- $dst : bool = false
Return values
stringgetClock()
public
getClock() : WrapperClock|null
Return values
WrapperClock|nullgetOffsetNameFromMinuteOffset()
Convert a total minutes offset into a standardized timezone offset string.
public
static getOffsetNameFromMinuteOffset(float $minutes) : string
Parameters
- $minutes : float
-
number of total minutes of the timezone shift.
Return values
stringgetType()
Return the type number:
public
getType() : int
Type 1; A UTC offset, such as -0300 Type 2; A timezone abbreviation, such as GMT Type 3: A timezone identifier, such as Europe/London
Return values
intinstance()
Create a CarbonTimeZone from mixed input.
public
static instance(DateTimeZone|string|int|false|null $object[, DateTimeZone|string|int|false|null $objectDump = null ]) : static|null
Parameters
- $object : DateTimeZone|string|int|false|null
-
original value to get CarbonTimeZone from it.
- $objectDump : DateTimeZone|string|int|false|null = null
-
dump of the object for error messages.
Tags
Return values
static|nulltoOffsetName()
Get the offset as string "sHH:MM" (such as "+00:00" or "-12:30").
public
toOffsetName([DateTimeInterface|null $date = null ]) : string
Parameters
- $date : DateTimeInterface|null = null
Return values
stringtoOffsetTimeZone()
Returns a new CarbonTimeZone object using the offset string instead of region string.
public
toOffsetTimeZone([DateTimeInterface|null $date = null ]) : static
Parameters
- $date : DateTimeInterface|null = null
Return values
statictoRegionName()
Returns the first region string (such as "America/Toronto") that matches the current timezone or false if no match is found.
public
toRegionName([DateTimeInterface|null $date = null ][, int $isDST = 1 ]) : string|null
Parameters
- $date : DateTimeInterface|null = null
- $isDST : int = 1
Tags
Return values
string|nulltoRegionTimeZone()
Returns a new CarbonTimeZone object using the region string instead of offset string.
public
toRegionTimeZone([DateTimeInterface|null $date = null ]) : self|null
Parameters
- $date : DateTimeInterface|null = null
Return values
self|nullgetDateTimeZoneNameFromMixed()
protected
static getDateTimeZoneNameFromMixed(string|int|float $timezone) : string
Parameters
- $timezone : string|int|float
Return values
stringparseNumericTimezone()
protected
static parseNumericTimezone(string|int|float $timezone) : string
Parameters
- $timezone : string|int|float
Return values
stringgetFactory()
private
getFactory() : Factory
Return values
FactoryinitLocalFactory()
private
initLocalFactory() : void
resolveCarbon()
private
resolveCarbon(DateTimeInterface|null $date) : DateTimeInterface
Parameters
- $date : DateTimeInterface|null
Return values
DateTimeInterfacetransmitFactory()
Trigger the given action using the local factory of the object, so it will be transmitted to any object also using this trait and calling initLocalFactory() in its constructor.
private
transmitFactory(Closure $action) : T
Parameters
- $action : Closure