2 @generated by mypy-protobuf. Do not edit manually!
6 import google.protobuf.descriptor
7 import google.protobuf.internal.well_known_types
8 import google.protobuf.message
9 import typing_extensions
11 DESCRIPTOR: google.protobuf.descriptor.FileDescriptor = ...
13 class Timestamp(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Timestamp):
14 """A Timestamp represents a point in time independent of any time zone or local
15 calendar, encoded as a count of seconds and fractions of seconds at
16 nanosecond resolution. The count is relative to an epoch at UTC midnight on
17 January 1, 1970, in the proleptic Gregorian calendar which extends the
18 Gregorian calendar backwards to year one.
20 All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
21 second table is needed for interpretation, using a [24-hour linear
22 smear](https://developers.google.com/time/smear).
24 The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
25 restricting to that range, we ensure that we can convert to and from [RFC
26 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
30 Example 1: Compute Timestamp from POSIX `time()`.
33 timestamp.set_seconds(time(NULL));
34 timestamp.set_nanos(0);
36 Example 2: Compute Timestamp from POSIX `gettimeofday()`.
39 gettimeofday(&tv, NULL);
42 timestamp.set_seconds(tv.tv_sec);
43 timestamp.set_nanos(tv.tv_usec * 1000);
45 Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
48 GetSystemTimeAsFileTime(&ft);
49 UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
51 // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
52 // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
54 timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
55 timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
57 Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
59 long millis = System.currentTimeMillis();
61 Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
62 .setNanos((int) ((millis % 1000) * 1000000)).build();
65 Example 5: Compute Timestamp from Java `Instant.now()`.
67 Instant now = Instant.now();
70 Timestamp.newBuilder().setSeconds(now.getEpochSecond())
71 .setNanos(now.getNano()).build();
74 Example 6: Compute Timestamp from current time in Python.
76 timestamp = Timestamp()
77 timestamp.GetCurrentTime()
81 In JSON format, the Timestamp type is encoded as a string in the
82 [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
83 format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
84 where {year} is always expressed using four digits while {month}, {day},
85 {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
86 seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
87 are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
88 is required. A proto3 JSON serializer should always use UTC (as indicated by
89 "Z") when printing the Timestamp type and a proto3 JSON parser should be
90 able to accept both UTC and other timezones (as indicated by an offset).
92 For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
93 01:30 UTC on January 15, 2017.
95 In JavaScript, one can convert a Date object to this format using the
97 [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
98 method. In Python, a standard `datetime.datetime` object can be converted
100 [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
101 the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
102 the Joda Time's [`ISODateTimeFormat.dateTime()`](
103 http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
104 ) to obtain a formatter capable of generating timestamps in this format.
106 DESCRIPTOR: google.protobuf.descriptor.Descriptor = ...
107 SECONDS_FIELD_NUMBER: builtins.int
108 NANOS_FIELD_NUMBER: builtins.int
109 seconds: builtins.int = ...
110 """Represents seconds of UTC time since Unix epoch
111 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
112 9999-12-31T23:59:59Z inclusive.
115 nanos: builtins.int = ...
116 """Non-negative fractions of a second at nanosecond resolution. Negative
117 second values with fractions must still have non-negative nanos values
118 that count forward in time. Must be from 0 to 999,999,999
124 seconds : builtins.int = ...,
125 nanos : builtins.int = ...,
127 def ClearField(self, field_name: typing_extensions.Literal["nanos",b"nanos","seconds",b"seconds"]) -> None: ...
128 global___Timestamp = Timestamp