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