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