Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GPBUtil.php

function GPBUtil::formatTimestamp

2 calls to GPBUtil::formatTimestamp()
Message::jsonByteSize in vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php
@ignore
Message::serializeToJsonStream in vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php
@ignore

File

vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php, line 488

Class

GPBUtil

Namespace

Google\Protobuf\Internal

Code

public static function formatTimestamp($value) {
    if (bccomp($value->getSeconds(), "253402300800") != -1) {
        throw new GPBDecodeException("Duration number too large.");
    }
    if (bccomp($value->getSeconds(), "-62135596801") != 1) {
        throw new GPBDecodeException("Duration number too small.");
    }
    $nanoseconds = static::getNanosecondsForTimestamp($value->getNanos());
    if (!empty($nanoseconds)) {
        $nanoseconds = "." . $nanoseconds;
    }
    $date = new \DateTime('@' . $value->getSeconds(), new \DateTimeZone("UTC"));
    return $date->format("Y-m-d\\TH:i:s" . $nanoseconds . "\\Z");
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal