| 1 |
<?php |
| 2 |
# Generated by the protocol buffer compiler. DO NOT EDIT! |
| 3 |
# source: google/protobuf/timestamp.proto |
| 4 |
|
| 5 |
namespace Google\Protobuf; |
| 6 |
|
| 7 |
use Google\Protobuf\Internal\GPBType; |
| 8 |
use Google\Protobuf\Internal\RepeatedField; |
| 9 |
use Google\Protobuf\Internal\GPBUtil; |
| 10 |
|
| 11 |
/** |
| 12 |
* A Timestamp represents a point in time independent of any time zone or local |
| 13 |
* calendar, encoded as a count of seconds and fractions of seconds at |
| 14 |
* nanosecond resolution. The count is relative to an epoch at UTC midnight on |
| 15 |
* January 1, 1970, in the proleptic Gregorian calendar which extends the |
| 16 |
* Gregorian calendar backwards to year one. |
| 17 |
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap |
| 18 |
* second table is needed for interpretation, using a [24-hour linear |
| 19 |
* smear](https://developers.google.com/time/smear). |
| 20 |
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By |
| 21 |
* restricting to that range, we ensure that we can convert to and from [RFC |
| 22 |
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. |
| 23 |
* # Examples |
| 24 |
* Example 1: Compute Timestamp from POSIX `time()`. |
| 25 |
* Timestamp timestamp; |
| 26 |
* timestamp.set_seconds(time(NULL)); |
| 27 |
* timestamp.set_nanos(0); |
| 28 |
* Example 2: Compute Timestamp from POSIX `gettimeofday()`. |
| 29 |
* struct timeval tv; |
| 30 |
* gettimeofday(&tv, NULL); |
| 31 |
* Timestamp timestamp; |
| 32 |
* timestamp.set_seconds(tv.tv_sec); |
| 33 |
* timestamp.set_nanos(tv.tv_usec * 1000); |
| 34 |
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. |
| 35 |
* FILETIME ft; |
| 36 |
* GetSystemTimeAsFileTime(&ft); |
| 37 |
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; |
| 38 |
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z |
| 39 |
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. |
| 40 |
* Timestamp timestamp; |
| 41 |
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); |
| 42 |
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); |
| 43 |
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. |
| 44 |
* long millis = System.currentTimeMillis(); |
| 45 |
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) |
| 46 |
* .setNanos((int) ((millis % 1000) * 1000000)).build(); |
| 47 |
* Example 5: Compute Timestamp from Java `Instant.now()`. |
| 48 |
* Instant now = Instant.now(); |
| 49 |
* Timestamp timestamp = |
| 50 |
* Timestamp.newBuilder().setSeconds(now.getEpochSecond()) |
| 51 |
* .setNanos(now.getNano()).build(); |
| 52 |
* Example 6: Compute Timestamp from current time in Python. |
| 53 |
* timestamp = Timestamp() |
| 54 |
* timestamp.GetCurrentTime() |
| 55 |
* # JSON Mapping |
| 56 |
* In JSON format, the Timestamp type is encoded as a string in the |
| 57 |
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the |
| 58 |
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" |
| 59 |
* where {year} is always expressed using four digits while {month}, {day}, |
| 60 |
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional |
| 61 |
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), |
| 62 |
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone |
| 63 |
* is required. A proto3 JSON serializer should always use UTC (as indicated by |
| 64 |
* "Z") when printing the Timestamp type and a proto3 JSON parser should be |
| 65 |
* able to accept both UTC and other timezones (as indicated by an offset). |
| 66 |
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past |
| 67 |
* 01:30 UTC on January 15, 2017. |
| 68 |
* In JavaScript, one can convert a Date object to this format using the |
| 69 |
* standard |
| 70 |
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) |
| 71 |
* method. In Python, a standard `datetime.datetime` object can be converted |
| 72 |
* to this format using |
| 73 |
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with |
| 74 |
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use |
| 75 |
* the Joda Time's [`ISODateTimeFormat.dateTime()`]( |
| 76 |
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D |
| 77 |
* ) to obtain a formatter capable of generating timestamps in this format. |
| 78 |
* |
| 79 |
* Generated from protobuf message <code>google.protobuf.Timestamp</code> |
| 80 |
*/ |
| 81 |
class Timestamp extends \Google\Protobuf\Internal\TimestampBase |
| 82 |
{ |
| 83 |
/** |
| 84 |
* Represents seconds of UTC time since Unix epoch |
| 85 |
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
| 86 |
* 9999-12-31T23:59:59Z inclusive. |
| 87 |
* |
| 88 |
* Generated from protobuf field <code>int64 seconds = 1;</code> |
| 89 |
*/ |
| 90 |
protected $seconds = 0; |
| 91 |
/** |
| 92 |
* Non-negative fractions of a second at nanosecond resolution. Negative |
| 93 |
* second values with fractions must still have non-negative nanos values |
| 94 |
* that count forward in time. Must be from 0 to 999,999,999 |
| 95 |
* inclusive. |
| 96 |
* |
| 97 |
* Generated from protobuf field <code>int32 nanos = 2;</code> |
| 98 |
*/ |
| 99 |
protected $nanos = 0; |
| 100 |
|
| 101 |
/** |
| 102 |
* Constructor. |
| 103 |
* |
| 104 |
* @param array $data { |
| 105 |
* Optional. Data for populating the Message object. |
| 106 |
* |
| 107 |
* @type int|string $seconds |
| 108 |
* Represents seconds of UTC time since Unix epoch |
| 109 |
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
| 110 |
* 9999-12-31T23:59:59Z inclusive. |
| 111 |
* @type int $nanos |
| 112 |
* Non-negative fractions of a second at nanosecond resolution. Negative |
| 113 |
* second values with fractions must still have non-negative nanos values |
| 114 |
* that count forward in time. Must be from 0 to 999,999,999 |
| 115 |
* inclusive. |
| 116 |
* } |
| 117 |
*/ |
| 118 |
public function __construct($data = NULL) { |
| 119 |
\GPBMetadata\Google\Protobuf\Timestamp::initOnce(); |
| 120 |
parent::__construct($data); |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Represents seconds of UTC time since Unix epoch |
| 125 |
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
| 126 |
* 9999-12-31T23:59:59Z inclusive. |
| 127 |
* |
| 128 |
* Generated from protobuf field <code>int64 seconds = 1;</code> |
| 129 |
* @return int|string |
| 130 |
*/ |
| 131 |
public function getSeconds() |
| 132 |
{ |
| 133 |
return $this->seconds; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Represents seconds of UTC time since Unix epoch |
| 138 |
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
| 139 |
* 9999-12-31T23:59:59Z inclusive. |
| 140 |
* |
| 141 |
* Generated from protobuf field <code>int64 seconds = 1;</code> |
| 142 |
* @param int|string $var |
| 143 |
* @return $this |
| 144 |
*/ |
| 145 |
public function setSeconds($var) |
| 146 |
{ |
| 147 |
GPBUtil::checkInt64($var); |
| 148 |
$this->seconds = $var; |
| 149 |
|
| 150 |
return $this; |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Non-negative fractions of a second at nanosecond resolution. Negative |
| 155 |
* second values with fractions must still have non-negative nanos values |
| 156 |
* that count forward in time. Must be from 0 to 999,999,999 |
| 157 |
* inclusive. |
| 158 |
* |
| 159 |
* Generated from protobuf field <code>int32 nanos = 2;</code> |
| 160 |
* @return int |
| 161 |
*/ |
| 162 |
public function getNanos() |
| 163 |
{ |
| 164 |
return $this->nanos; |
| 165 |
} |
| 166 |
|
| 167 |
/** |
| 168 |
* Non-negative fractions of a second at nanosecond resolution. Negative |
| 169 |
* second values with fractions must still have non-negative nanos values |
| 170 |
* that count forward in time. Must be from 0 to 999,999,999 |
| 171 |
* inclusive. |
| 172 |
* |
| 173 |
* Generated from protobuf field <code>int32 nanos = 2;</code> |
| 174 |
* @param int $var |
| 175 |
* @return $this |
| 176 |
*/ |
| 177 |
public function setNanos($var) |
| 178 |
{ |
| 179 |
GPBUtil::checkInt32($var); |
| 180 |
$this->nanos = $var; |
| 181 |
|
| 182 |
return $this; |
| 183 |
} |
| 184 |
|
| 185 |
} |
| 186 |
|