summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/sdk/Common/Time/Util.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/open-telemetry/sdk/Common/Time/Util.php')
-rw-r--r--vendor/open-telemetry/sdk/Common/Time/Util.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/vendor/open-telemetry/sdk/Common/Time/Util.php b/vendor/open-telemetry/sdk/Common/Time/Util.php
new file mode 100644
index 000000000..e1be1f750
--- /dev/null
+++ b/vendor/open-telemetry/sdk/Common/Time/Util.php
@@ -0,0 +1,32 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OpenTelemetry\SDK\Common\Time;
+
+class Util
+{
+ /** @psalm-pure */
+ public static function nanosToMicros(int $nanoseconds): int
+ {
+ return intdiv($nanoseconds, ClockInterface::NANOS_PER_MICROSECOND);
+ }
+
+ /** @psalm-pure */
+ public static function nanosToMillis(int $nanoseconds): int
+ {
+ return intdiv($nanoseconds, ClockInterface::NANOS_PER_MILLISECOND);
+ }
+
+ /** @psalm-pure */
+ public static function secondsToNanos(int $seconds): int
+ {
+ return $seconds * ClockInterface::NANOS_PER_SECOND;
+ }
+
+ /** @psalm-pure */
+ public static function millisToNanos(int $milliSeconds): int
+ {
+ return $milliSeconds * ClockInterface::NANOS_PER_MILLISECOND;
+ }
+}