1ffe3c632Sopenharmony_ci<?php 2ffe3c632Sopenharmony_ci# Generated by the protocol buffer compiler. DO NOT EDIT! 3ffe3c632Sopenharmony_ci# source: google/protobuf/duration.proto 4ffe3c632Sopenharmony_ci 5ffe3c632Sopenharmony_cinamespace Google\Protobuf; 6ffe3c632Sopenharmony_ci 7ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\GPBType; 8ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\RepeatedField; 9ffe3c632Sopenharmony_ciuse Google\Protobuf\Internal\GPBUtil; 10ffe3c632Sopenharmony_ci 11ffe3c632Sopenharmony_ci/** 12ffe3c632Sopenharmony_ci * A Duration represents a signed, fixed-length span of time represented 13ffe3c632Sopenharmony_ci * as a count of seconds and fractions of seconds at nanosecond 14ffe3c632Sopenharmony_ci * resolution. It is independent of any calendar and concepts like "day" 15ffe3c632Sopenharmony_ci * or "month". It is related to Timestamp in that the difference between 16ffe3c632Sopenharmony_ci * two Timestamp values is a Duration and it can be added or subtracted 17ffe3c632Sopenharmony_ci * from a Timestamp. Range is approximately +-10,000 years. 18ffe3c632Sopenharmony_ci * # Examples 19ffe3c632Sopenharmony_ci * Example 1: Compute Duration from two Timestamps in pseudo code. 20ffe3c632Sopenharmony_ci * Timestamp start = ...; 21ffe3c632Sopenharmony_ci * Timestamp end = ...; 22ffe3c632Sopenharmony_ci * Duration duration = ...; 23ffe3c632Sopenharmony_ci * duration.seconds = end.seconds - start.seconds; 24ffe3c632Sopenharmony_ci * duration.nanos = end.nanos - start.nanos; 25ffe3c632Sopenharmony_ci * if (duration.seconds < 0 && duration.nanos > 0) { 26ffe3c632Sopenharmony_ci * duration.seconds += 1; 27ffe3c632Sopenharmony_ci * duration.nanos -= 1000000000; 28ffe3c632Sopenharmony_ci * } else if (durations.seconds > 0 && duration.nanos < 0) { 29ffe3c632Sopenharmony_ci * duration.seconds -= 1; 30ffe3c632Sopenharmony_ci * duration.nanos += 1000000000; 31ffe3c632Sopenharmony_ci * } 32ffe3c632Sopenharmony_ci * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 33ffe3c632Sopenharmony_ci * Timestamp start = ...; 34ffe3c632Sopenharmony_ci * Duration duration = ...; 35ffe3c632Sopenharmony_ci * Timestamp end = ...; 36ffe3c632Sopenharmony_ci * end.seconds = start.seconds + duration.seconds; 37ffe3c632Sopenharmony_ci * end.nanos = start.nanos + duration.nanos; 38ffe3c632Sopenharmony_ci * if (end.nanos < 0) { 39ffe3c632Sopenharmony_ci * end.seconds -= 1; 40ffe3c632Sopenharmony_ci * end.nanos += 1000000000; 41ffe3c632Sopenharmony_ci * } else if (end.nanos >= 1000000000) { 42ffe3c632Sopenharmony_ci * end.seconds += 1; 43ffe3c632Sopenharmony_ci * end.nanos -= 1000000000; 44ffe3c632Sopenharmony_ci * } 45ffe3c632Sopenharmony_ci * Example 3: Compute Duration from datetime.timedelta in Python. 46ffe3c632Sopenharmony_ci * td = datetime.timedelta(days=3, minutes=10) 47ffe3c632Sopenharmony_ci * duration = Duration() 48ffe3c632Sopenharmony_ci * duration.FromTimedelta(td) 49ffe3c632Sopenharmony_ci * # JSON Mapping 50ffe3c632Sopenharmony_ci * In JSON format, the Duration type is encoded as a string rather than an 51ffe3c632Sopenharmony_ci * object, where the string ends in the suffix "s" (indicating seconds) and 52ffe3c632Sopenharmony_ci * is preceded by the number of seconds, with nanoseconds expressed as 53ffe3c632Sopenharmony_ci * fractional seconds. For example, 3 seconds with 0 nanoseconds should be 54ffe3c632Sopenharmony_ci * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 55ffe3c632Sopenharmony_ci * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 56ffe3c632Sopenharmony_ci * microsecond should be expressed in JSON format as "3.000001s". 57ffe3c632Sopenharmony_ci * 58ffe3c632Sopenharmony_ci * Generated from protobuf message <code>google.protobuf.Duration</code> 59ffe3c632Sopenharmony_ci */ 60ffe3c632Sopenharmony_ciclass Duration extends \Google\Protobuf\Internal\Message 61ffe3c632Sopenharmony_ci{ 62ffe3c632Sopenharmony_ci /** 63ffe3c632Sopenharmony_ci * Signed seconds of the span of time. Must be from -315,576,000,000 64ffe3c632Sopenharmony_ci * to +315,576,000,000 inclusive. Note: these bounds are computed from: 65ffe3c632Sopenharmony_ci * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 66ffe3c632Sopenharmony_ci * 67ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int64 seconds = 1;</code> 68ffe3c632Sopenharmony_ci */ 69ffe3c632Sopenharmony_ci private $seconds = 0; 70ffe3c632Sopenharmony_ci /** 71ffe3c632Sopenharmony_ci * Signed fractions of a second at nanosecond resolution of the span 72ffe3c632Sopenharmony_ci * of time. Durations less than one second are represented with a 0 73ffe3c632Sopenharmony_ci * `seconds` field and a positive or negative `nanos` field. For durations 74ffe3c632Sopenharmony_ci * of one second or more, a non-zero value for the `nanos` field must be 75ffe3c632Sopenharmony_ci * of the same sign as the `seconds` field. Must be from -999,999,999 76ffe3c632Sopenharmony_ci * to +999,999,999 inclusive. 77ffe3c632Sopenharmony_ci * 78ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int32 nanos = 2;</code> 79ffe3c632Sopenharmony_ci */ 80ffe3c632Sopenharmony_ci private $nanos = 0; 81ffe3c632Sopenharmony_ci 82ffe3c632Sopenharmony_ci /** 83ffe3c632Sopenharmony_ci * Constructor. 84ffe3c632Sopenharmony_ci * 85ffe3c632Sopenharmony_ci * @param array $data { 86ffe3c632Sopenharmony_ci * Optional. Data for populating the Message object. 87ffe3c632Sopenharmony_ci * 88ffe3c632Sopenharmony_ci * @type int|string $seconds 89ffe3c632Sopenharmony_ci * Signed seconds of the span of time. Must be from -315,576,000,000 90ffe3c632Sopenharmony_ci * to +315,576,000,000 inclusive. Note: these bounds are computed from: 91ffe3c632Sopenharmony_ci * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 92ffe3c632Sopenharmony_ci * @type int $nanos 93ffe3c632Sopenharmony_ci * Signed fractions of a second at nanosecond resolution of the span 94ffe3c632Sopenharmony_ci * of time. Durations less than one second are represented with a 0 95ffe3c632Sopenharmony_ci * `seconds` field and a positive or negative `nanos` field. For durations 96ffe3c632Sopenharmony_ci * of one second or more, a non-zero value for the `nanos` field must be 97ffe3c632Sopenharmony_ci * of the same sign as the `seconds` field. Must be from -999,999,999 98ffe3c632Sopenharmony_ci * to +999,999,999 inclusive. 99ffe3c632Sopenharmony_ci * } 100ffe3c632Sopenharmony_ci */ 101ffe3c632Sopenharmony_ci public function __construct($data = NULL) { 102ffe3c632Sopenharmony_ci \GPBMetadata\Google\Protobuf\Duration::initOnce(); 103ffe3c632Sopenharmony_ci parent::__construct($data); 104ffe3c632Sopenharmony_ci } 105ffe3c632Sopenharmony_ci 106ffe3c632Sopenharmony_ci /** 107ffe3c632Sopenharmony_ci * Signed seconds of the span of time. Must be from -315,576,000,000 108ffe3c632Sopenharmony_ci * to +315,576,000,000 inclusive. Note: these bounds are computed from: 109ffe3c632Sopenharmony_ci * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 110ffe3c632Sopenharmony_ci * 111ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int64 seconds = 1;</code> 112ffe3c632Sopenharmony_ci * @return int|string 113ffe3c632Sopenharmony_ci */ 114ffe3c632Sopenharmony_ci public function getSeconds() 115ffe3c632Sopenharmony_ci { 116ffe3c632Sopenharmony_ci return $this->seconds; 117ffe3c632Sopenharmony_ci } 118ffe3c632Sopenharmony_ci 119ffe3c632Sopenharmony_ci /** 120ffe3c632Sopenharmony_ci * Signed seconds of the span of time. Must be from -315,576,000,000 121ffe3c632Sopenharmony_ci * to +315,576,000,000 inclusive. Note: these bounds are computed from: 122ffe3c632Sopenharmony_ci * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 123ffe3c632Sopenharmony_ci * 124ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int64 seconds = 1;</code> 125ffe3c632Sopenharmony_ci * @param int|string $var 126ffe3c632Sopenharmony_ci * @return $this 127ffe3c632Sopenharmony_ci */ 128ffe3c632Sopenharmony_ci public function setSeconds($var) 129ffe3c632Sopenharmony_ci { 130ffe3c632Sopenharmony_ci GPBUtil::checkInt64($var); 131ffe3c632Sopenharmony_ci $this->seconds = $var; 132ffe3c632Sopenharmony_ci 133ffe3c632Sopenharmony_ci return $this; 134ffe3c632Sopenharmony_ci } 135ffe3c632Sopenharmony_ci 136ffe3c632Sopenharmony_ci /** 137ffe3c632Sopenharmony_ci * Signed fractions of a second at nanosecond resolution of the span 138ffe3c632Sopenharmony_ci * of time. Durations less than one second are represented with a 0 139ffe3c632Sopenharmony_ci * `seconds` field and a positive or negative `nanos` field. For durations 140ffe3c632Sopenharmony_ci * of one second or more, a non-zero value for the `nanos` field must be 141ffe3c632Sopenharmony_ci * of the same sign as the `seconds` field. Must be from -999,999,999 142ffe3c632Sopenharmony_ci * to +999,999,999 inclusive. 143ffe3c632Sopenharmony_ci * 144ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int32 nanos = 2;</code> 145ffe3c632Sopenharmony_ci * @return int 146ffe3c632Sopenharmony_ci */ 147ffe3c632Sopenharmony_ci public function getNanos() 148ffe3c632Sopenharmony_ci { 149ffe3c632Sopenharmony_ci return $this->nanos; 150ffe3c632Sopenharmony_ci } 151ffe3c632Sopenharmony_ci 152ffe3c632Sopenharmony_ci /** 153ffe3c632Sopenharmony_ci * Signed fractions of a second at nanosecond resolution of the span 154ffe3c632Sopenharmony_ci * of time. Durations less than one second are represented with a 0 155ffe3c632Sopenharmony_ci * `seconds` field and a positive or negative `nanos` field. For durations 156ffe3c632Sopenharmony_ci * of one second or more, a non-zero value for the `nanos` field must be 157ffe3c632Sopenharmony_ci * of the same sign as the `seconds` field. Must be from -999,999,999 158ffe3c632Sopenharmony_ci * to +999,999,999 inclusive. 159ffe3c632Sopenharmony_ci * 160ffe3c632Sopenharmony_ci * Generated from protobuf field <code>int32 nanos = 2;</code> 161ffe3c632Sopenharmony_ci * @param int $var 162ffe3c632Sopenharmony_ci * @return $this 163ffe3c632Sopenharmony_ci */ 164ffe3c632Sopenharmony_ci public function setNanos($var) 165ffe3c632Sopenharmony_ci { 166ffe3c632Sopenharmony_ci GPBUtil::checkInt32($var); 167ffe3c632Sopenharmony_ci $this->nanos = $var; 168ffe3c632Sopenharmony_ci 169ffe3c632Sopenharmony_ci return $this; 170ffe3c632Sopenharmony_ci } 171ffe3c632Sopenharmony_ci 172ffe3c632Sopenharmony_ci} 173ffe3c632Sopenharmony_ci 174