xref: /aosp_15_r20/external/cronet/third_party/protobuf/objectivec/GPBTimestamp.pbobjc.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1*6777b538SAndroid Build Coastguard Worker // Generated by the protocol buffer compiler.  DO NOT EDIT!
2*6777b538SAndroid Build Coastguard Worker // source: google/protobuf/timestamp.proto
3*6777b538SAndroid Build Coastguard Worker 
4*6777b538SAndroid Build Coastguard Worker #import "GPBDescriptor.h"
5*6777b538SAndroid Build Coastguard Worker #import "GPBMessage.h"
6*6777b538SAndroid Build Coastguard Worker #import "GPBRootObject.h"
7*6777b538SAndroid Build Coastguard Worker 
8*6777b538SAndroid Build Coastguard Worker #if GOOGLE_PROTOBUF_OBJC_VERSION < 30004
9*6777b538SAndroid Build Coastguard Worker #error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
10*6777b538SAndroid Build Coastguard Worker #endif
11*6777b538SAndroid Build Coastguard Worker #if 30004 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
12*6777b538SAndroid Build Coastguard Worker #error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
13*6777b538SAndroid Build Coastguard Worker #endif
14*6777b538SAndroid Build Coastguard Worker 
15*6777b538SAndroid Build Coastguard Worker // @@protoc_insertion_point(imports)
16*6777b538SAndroid Build Coastguard Worker 
17*6777b538SAndroid Build Coastguard Worker #pragma clang diagnostic push
18*6777b538SAndroid Build Coastguard Worker #pragma clang diagnostic ignored "-Wdeprecated-declarations"
19*6777b538SAndroid Build Coastguard Worker 
20*6777b538SAndroid Build Coastguard Worker CF_EXTERN_C_BEGIN
21*6777b538SAndroid Build Coastguard Worker 
22*6777b538SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_BEGIN
23*6777b538SAndroid Build Coastguard Worker 
24*6777b538SAndroid Build Coastguard Worker #pragma mark - GPBTimestampRoot
25*6777b538SAndroid Build Coastguard Worker 
26*6777b538SAndroid Build Coastguard Worker /**
27*6777b538SAndroid Build Coastguard Worker  * Exposes the extension registry for this file.
28*6777b538SAndroid Build Coastguard Worker  *
29*6777b538SAndroid Build Coastguard Worker  * The base class provides:
30*6777b538SAndroid Build Coastguard Worker  * @code
31*6777b538SAndroid Build Coastguard Worker  *   + (GPBExtensionRegistry *)extensionRegistry;
32*6777b538SAndroid Build Coastguard Worker  * @endcode
33*6777b538SAndroid Build Coastguard Worker  * which is a @c GPBExtensionRegistry that includes all the extensions defined by
34*6777b538SAndroid Build Coastguard Worker  * this file and all files that it depends on.
35*6777b538SAndroid Build Coastguard Worker  **/
36*6777b538SAndroid Build Coastguard Worker GPB_FINAL @interface GPBTimestampRoot : GPBRootObject
37*6777b538SAndroid Build Coastguard Worker @end
38*6777b538SAndroid Build Coastguard Worker 
39*6777b538SAndroid Build Coastguard Worker #pragma mark - GPBTimestamp
40*6777b538SAndroid Build Coastguard Worker 
41*6777b538SAndroid Build Coastguard Worker typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
42*6777b538SAndroid Build Coastguard Worker   GPBTimestamp_FieldNumber_Seconds = 1,
43*6777b538SAndroid Build Coastguard Worker   GPBTimestamp_FieldNumber_Nanos = 2,
44*6777b538SAndroid Build Coastguard Worker };
45*6777b538SAndroid Build Coastguard Worker 
46*6777b538SAndroid Build Coastguard Worker /**
47*6777b538SAndroid Build Coastguard Worker  * A Timestamp represents a point in time independent of any time zone or local
48*6777b538SAndroid Build Coastguard Worker  * calendar, encoded as a count of seconds and fractions of seconds at
49*6777b538SAndroid Build Coastguard Worker  * nanosecond resolution. The count is relative to an epoch at UTC midnight on
50*6777b538SAndroid Build Coastguard Worker  * January 1, 1970, in the proleptic Gregorian calendar which extends the
51*6777b538SAndroid Build Coastguard Worker  * Gregorian calendar backwards to year one.
52*6777b538SAndroid Build Coastguard Worker  *
53*6777b538SAndroid Build Coastguard Worker  * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
54*6777b538SAndroid Build Coastguard Worker  * second table is needed for interpretation, using a [24-hour linear
55*6777b538SAndroid Build Coastguard Worker  * smear](https://developers.google.com/time/smear).
56*6777b538SAndroid Build Coastguard Worker  *
57*6777b538SAndroid Build Coastguard Worker  * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
58*6777b538SAndroid Build Coastguard Worker  * restricting to that range, we ensure that we can convert to and from [RFC
59*6777b538SAndroid Build Coastguard Worker  * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
60*6777b538SAndroid Build Coastguard Worker  *
61*6777b538SAndroid Build Coastguard Worker  * # Examples
62*6777b538SAndroid Build Coastguard Worker  *
63*6777b538SAndroid Build Coastguard Worker  * Example 1: Compute Timestamp from POSIX `time()`.
64*6777b538SAndroid Build Coastguard Worker  *
65*6777b538SAndroid Build Coastguard Worker  *     Timestamp timestamp;
66*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_seconds(time(NULL));
67*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_nanos(0);
68*6777b538SAndroid Build Coastguard Worker  *
69*6777b538SAndroid Build Coastguard Worker  * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
70*6777b538SAndroid Build Coastguard Worker  *
71*6777b538SAndroid Build Coastguard Worker  *     struct timeval tv;
72*6777b538SAndroid Build Coastguard Worker  *     gettimeofday(&tv, NULL);
73*6777b538SAndroid Build Coastguard Worker  *
74*6777b538SAndroid Build Coastguard Worker  *     Timestamp timestamp;
75*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_seconds(tv.tv_sec);
76*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_nanos(tv.tv_usec * 1000);
77*6777b538SAndroid Build Coastguard Worker  *
78*6777b538SAndroid Build Coastguard Worker  * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
79*6777b538SAndroid Build Coastguard Worker  *
80*6777b538SAndroid Build Coastguard Worker  *     FILETIME ft;
81*6777b538SAndroid Build Coastguard Worker  *     GetSystemTimeAsFileTime(&ft);
82*6777b538SAndroid Build Coastguard Worker  *     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
83*6777b538SAndroid Build Coastguard Worker  *
84*6777b538SAndroid Build Coastguard Worker  *     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
85*6777b538SAndroid Build Coastguard Worker  *     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
86*6777b538SAndroid Build Coastguard Worker  *     Timestamp timestamp;
87*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
88*6777b538SAndroid Build Coastguard Worker  *     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
89*6777b538SAndroid Build Coastguard Worker  *
90*6777b538SAndroid Build Coastguard Worker  * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
91*6777b538SAndroid Build Coastguard Worker  *
92*6777b538SAndroid Build Coastguard Worker  *     long millis = System.currentTimeMillis();
93*6777b538SAndroid Build Coastguard Worker  *
94*6777b538SAndroid Build Coastguard Worker  *     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
95*6777b538SAndroid Build Coastguard Worker  *         .setNanos((int) ((millis % 1000) * 1000000)).build();
96*6777b538SAndroid Build Coastguard Worker  *
97*6777b538SAndroid Build Coastguard Worker  *
98*6777b538SAndroid Build Coastguard Worker  * Example 5: Compute Timestamp from Java `Instant.now()`.
99*6777b538SAndroid Build Coastguard Worker  *
100*6777b538SAndroid Build Coastguard Worker  *     Instant now = Instant.now();
101*6777b538SAndroid Build Coastguard Worker  *
102*6777b538SAndroid Build Coastguard Worker  *     Timestamp timestamp =
103*6777b538SAndroid Build Coastguard Worker  *         Timestamp.newBuilder().setSeconds(now.getEpochSecond())
104*6777b538SAndroid Build Coastguard Worker  *             .setNanos(now.getNano()).build();
105*6777b538SAndroid Build Coastguard Worker  *
106*6777b538SAndroid Build Coastguard Worker  *
107*6777b538SAndroid Build Coastguard Worker  * Example 6: Compute Timestamp from current time in Python.
108*6777b538SAndroid Build Coastguard Worker  *
109*6777b538SAndroid Build Coastguard Worker  *     timestamp = Timestamp()
110*6777b538SAndroid Build Coastguard Worker  *     timestamp.GetCurrentTime()
111*6777b538SAndroid Build Coastguard Worker  *
112*6777b538SAndroid Build Coastguard Worker  * # JSON Mapping
113*6777b538SAndroid Build Coastguard Worker  *
114*6777b538SAndroid Build Coastguard Worker  * In JSON format, the Timestamp type is encoded as a string in the
115*6777b538SAndroid Build Coastguard Worker  * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
116*6777b538SAndroid Build Coastguard Worker  * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
117*6777b538SAndroid Build Coastguard Worker  * where {year} is always expressed using four digits while {month}, {day},
118*6777b538SAndroid Build Coastguard Worker  * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
119*6777b538SAndroid Build Coastguard Worker  * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
120*6777b538SAndroid Build Coastguard Worker  * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
121*6777b538SAndroid Build Coastguard Worker  * is required. A proto3 JSON serializer should always use UTC (as indicated by
122*6777b538SAndroid Build Coastguard Worker  * "Z") when printing the Timestamp type and a proto3 JSON parser should be
123*6777b538SAndroid Build Coastguard Worker  * able to accept both UTC and other timezones (as indicated by an offset).
124*6777b538SAndroid Build Coastguard Worker  *
125*6777b538SAndroid Build Coastguard Worker  * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
126*6777b538SAndroid Build Coastguard Worker  * 01:30 UTC on January 15, 2017.
127*6777b538SAndroid Build Coastguard Worker  *
128*6777b538SAndroid Build Coastguard Worker  * In JavaScript, one can convert a Date object to this format using the
129*6777b538SAndroid Build Coastguard Worker  * standard
130*6777b538SAndroid Build Coastguard Worker  * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
131*6777b538SAndroid Build Coastguard Worker  * method. In Python, a standard `datetime.datetime` object can be converted
132*6777b538SAndroid Build Coastguard Worker  * to this format using
133*6777b538SAndroid Build Coastguard Worker  * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
134*6777b538SAndroid Build Coastguard Worker  * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
135*6777b538SAndroid Build Coastguard Worker  * the Joda Time's [`ISODateTimeFormat.dateTime()`](
136*6777b538SAndroid Build Coastguard Worker  * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
137*6777b538SAndroid Build Coastguard Worker  * ) to obtain a formatter capable of generating timestamps in this format.
138*6777b538SAndroid Build Coastguard Worker  **/
139*6777b538SAndroid Build Coastguard Worker GPB_FINAL @interface GPBTimestamp : GPBMessage
140*6777b538SAndroid Build Coastguard Worker 
141*6777b538SAndroid Build Coastguard Worker /**
142*6777b538SAndroid Build Coastguard Worker  * Represents seconds of UTC time since Unix epoch
143*6777b538SAndroid Build Coastguard Worker  * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
144*6777b538SAndroid Build Coastguard Worker  * 9999-12-31T23:59:59Z inclusive.
145*6777b538SAndroid Build Coastguard Worker  **/
146*6777b538SAndroid Build Coastguard Worker @property(nonatomic, readwrite) int64_t seconds;
147*6777b538SAndroid Build Coastguard Worker 
148*6777b538SAndroid Build Coastguard Worker /**
149*6777b538SAndroid Build Coastguard Worker  * Non-negative fractions of a second at nanosecond resolution. Negative
150*6777b538SAndroid Build Coastguard Worker  * second values with fractions must still have non-negative nanos values
151*6777b538SAndroid Build Coastguard Worker  * that count forward in time. Must be from 0 to 999,999,999
152*6777b538SAndroid Build Coastguard Worker  * inclusive.
153*6777b538SAndroid Build Coastguard Worker  **/
154*6777b538SAndroid Build Coastguard Worker @property(nonatomic, readwrite) int32_t nanos;
155*6777b538SAndroid Build Coastguard Worker 
156*6777b538SAndroid Build Coastguard Worker @end
157*6777b538SAndroid Build Coastguard Worker 
158*6777b538SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_END
159*6777b538SAndroid Build Coastguard Worker 
160*6777b538SAndroid Build Coastguard Worker CF_EXTERN_C_END
161*6777b538SAndroid Build Coastguard Worker 
162*6777b538SAndroid Build Coastguard Worker #pragma clang diagnostic pop
163*6777b538SAndroid Build Coastguard Worker 
164*6777b538SAndroid Build Coastguard Worker // @@protoc_insertion_point(global_scope)
165