PhpTimeConverter
in package
implements
TimeConverterInterface
PhpTimeConverter uses built-in PHP functions and standard math operations available to the PHP programming language to provide facilities for converting parts of time into representations that may be used in UUIDs
Tags
Interfaces, Classes, Traits and Enums
- TimeConverterInterface
- A time converter converts timestamps into representations that may be used in UUIDs
Table of Contents
- GREGORIAN_TO_UNIX_INTERVALS = 0x1b21dd213814000
- The number of 100-nanosecond intervals from the Gregorian calendar epoch to the Unix epoch.
- MICROSECOND_INTERVALS = 10
- The number of 100-nanosecond intervals in one microsecond.
- SECOND_INTERVALS = 10000000
- The number of 100-nanosecond intervals in one second.
- $calculator : CalculatorInterface
- $fallbackConverter : TimeConverterInterface
- $phpPrecision : int
- __construct() : mixed
- calculateTime() : Hexadecimal
- Uses the provided seconds and micro-seconds to calculate the count of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582, for RFC 4122 variant UUIDs
- convertTime() : Time
- Converts a timestamp extracted from a UUID to a Unix timestamp
- splitTime() : array<string|int, string>
Constants
GREGORIAN_TO_UNIX_INTERVALS
The number of 100-nanosecond intervals from the Gregorian calendar epoch to the Unix epoch.
private
mixed
GREGORIAN_TO_UNIX_INTERVALS
= 0x1b21dd213814000
MICROSECOND_INTERVALS
The number of 100-nanosecond intervals in one microsecond.
private
mixed
MICROSECOND_INTERVALS
= 10
SECOND_INTERVALS
The number of 100-nanosecond intervals in one second.
private
mixed
SECOND_INTERVALS
= 10000000
Properties
$calculator
private
CalculatorInterface
$calculator
$fallbackConverter
private
TimeConverterInterface
$fallbackConverter
$phpPrecision
private
int
$phpPrecision
Methods
__construct()
public
__construct([CalculatorInterface|null $calculator = null ][, TimeConverterInterface|null $fallbackConverter = null ]) : mixed
Parameters
- $calculator : CalculatorInterface|null = null
- $fallbackConverter : TimeConverterInterface|null = null
Return values
mixed —calculateTime()
Uses the provided seconds and micro-seconds to calculate the count of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582, for RFC 4122 variant UUIDs
public
calculateTime(string $seconds, string $microseconds) : Hexadecimal
Parameters
- $seconds : string
-
A string representation of the number of seconds since the Unix epoch for the time to calculate
- $microseconds : string
-
A string representation of the micro-seconds associated with the time to calculate
Return values
Hexadecimal —The full UUID timestamp as a Hexadecimal value
convertTime()
Converts a timestamp extracted from a UUID to a Unix timestamp
public
convertTime(Hexadecimal $uuidTimestamp) : Time
Parameters
- $uuidTimestamp : Hexadecimal
-
A hexadecimal representation of a UUID timestamp; a UUID timestamp is a count of 100-nanosecond intervals since UTC 00:00:00.00, 15 October 1582.
Return values
Time —An instance of Time
splitTime()
private
splitTime(int|float $time) : array<string|int, string>
Parameters
- $time : int|float
-
The time to split into seconds and microseconds