Helper methods for formatting and converting Timestamps.

Trait
Methods
private convertFractionToNanoSeconds( $subseconds)
 
Convert subseconds, expressed as a decimal to nanoseconds.

  • return int
private convertNanoSecondsToFraction( $nanos, $rpad = true)
 
Convert nanoseconds to subseconds.

Note that result should be used as a fraction of one second, but is
given as an integer.

  • return string
private createDateTimeFromSeconds( $seconds)
 
Create a DateTimeImmutable instance from a UNIX timestamp (i.e. seconds since epoch).

  • return DateTimeImmutable
private formatTimeAsArray(DateTimeInterface $dateTime, $ns)
 
Format a timestamp for the API with nanosecond precision.

  • return array
private formatTimeAsString(DateTimeInterface $dateTime, $ns)
 
Create a Timestamp string in an API-compatible format.

  • return string
private parseTimeString( $timestamp)
 
Parse a Timestamp string and return a DateTimeImmutable instance and nanoseconds as an integer.

  • return array [\DateTimeImmutable, int]
  • throws Exception If the timestamp string is in an unrecognized format.
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only