GenericTimeConverter
in package
implements
TimeConverterInterface
GenericTimeConverter uses the provided calculator to calculate and convert time values
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 = '122192928000000000'
- 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
- __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
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
= '122192928000000000'
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
Methods
__construct()
public
__construct(CalculatorInterface $calculator) : mixed
Parameters
- $calculator : CalculatorInterface
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