|
1 | | -import { Writer, Reader } from 'protobufjs/minimal'; |
2 | | -/** |
3 | | - * A Timestamp represents a point in time independent of any time zone or local |
4 | | - * calendar, encoded as a count of seconds and fractions of seconds at |
5 | | - * nanosecond resolution. The count is relative to an epoch at UTC midnight on |
6 | | - * January 1, 1970, in the proleptic Gregorian calendar which extends the |
7 | | - * Gregorian calendar backwards to year one. |
8 | | - * |
9 | | - * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap |
10 | | - * second table is needed for interpretation, using a [24-hour linear |
11 | | - * smear](https://developers.google.com/time/smear). |
12 | | - * |
13 | | - * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By |
14 | | - * restricting to that range, we ensure that we can convert to and from [RFC |
15 | | - * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. |
16 | | - * |
17 | | - * # Examples |
18 | | - * |
19 | | - * Example 1: Compute Timestamp from POSIX `time()`. |
20 | | - * |
21 | | - * Timestamp timestamp; |
22 | | - * timestamp.set_seconds(time(NULL)); |
23 | | - * timestamp.set_nanos(0); |
24 | | - * |
25 | | - * Example 2: Compute Timestamp from POSIX `gettimeofday()`. |
26 | | - * |
27 | | - * struct timeval tv; |
28 | | - * gettimeofday(&tv, NULL); |
29 | | - * |
30 | | - * Timestamp timestamp; |
31 | | - * timestamp.set_seconds(tv.tv_sec); |
32 | | - * timestamp.set_nanos(tv.tv_usec * 1000); |
33 | | - * |
34 | | - * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. |
35 | | - * |
36 | | - * FILETIME ft; |
37 | | - * GetSystemTimeAsFileTime(&ft); |
38 | | - * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; |
39 | | - * |
40 | | - * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z |
41 | | - * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. |
42 | | - * Timestamp timestamp; |
43 | | - * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); |
44 | | - * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); |
45 | | - * |
46 | | - * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. |
47 | | - * |
48 | | - * long millis = System.currentTimeMillis(); |
49 | | - * |
50 | | - * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) |
51 | | - * .setNanos((int) ((millis % 1000) * 1000000)).build(); |
52 | | - * |
53 | | - * |
54 | | - * Example 5: Compute Timestamp from current time in Python. |
55 | | - * |
56 | | - * timestamp = Timestamp() |
57 | | - * timestamp.GetCurrentTime() |
58 | | - * |
59 | | - * # JSON Mapping |
60 | | - * |
61 | | - * In JSON format, the Timestamp type is encoded as a string in the |
62 | | - * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the |
63 | | - * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" |
64 | | - * where {year} is always expressed using four digits while {month}, {day}, |
65 | | - * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional |
66 | | - * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), |
67 | | - * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone |
68 | | - * is required. A proto3 JSON serializer should always use UTC (as indicated by |
69 | | - * "Z") when printing the Timestamp type and a proto3 JSON parser should be |
70 | | - * able to accept both UTC and other timezones (as indicated by an offset). |
71 | | - * |
72 | | - * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past |
73 | | - * 01:30 UTC on January 15, 2017. |
74 | | - * |
75 | | - * In JavaScript, one can convert a Date object to this format using the |
76 | | - * standard |
77 | | - * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) |
78 | | - * method. In Python, a standard `datetime.datetime` object can be converted |
79 | | - * to this format using |
80 | | - * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with |
81 | | - * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use |
82 | | - * the Joda Time's [`ISODateTimeFormat.dateTime()`]( |
83 | | - * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D |
84 | | - * ) to obtain a formatter capable of generating timestamps in this format. |
85 | | - * |
86 | | - * |
87 | | - */ |
88 | | -export interface Timestamp { |
89 | | - /** |
90 | | - * Represents seconds of UTC time since Unix epoch |
91 | | - * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
92 | | - * 9999-12-31T23:59:59Z inclusive. |
93 | | - */ |
94 | | - seconds: number; |
95 | | - /** |
96 | | - * Non-negative fractions of a second at nanosecond resolution. Negative |
97 | | - * second values with fractions must still have non-negative nanos values |
98 | | - * that count forward in time. Must be from 0 to 999,999,999 |
99 | | - * inclusive. |
100 | | - */ |
101 | | - nanos: number; |
102 | | -} |
103 | | -export declare const protobufPackage = "google.protobuf"; |
104 | | -export declare const Timestamp: { |
105 | | - encode(message: Timestamp, writer?: Writer): Writer; |
106 | | - decode(input: Uint8Array | Reader, length?: number): Timestamp; |
107 | | - fromJSON(object: any): Timestamp; |
108 | | - fromPartial(object: DeepPartial<Timestamp>): Timestamp; |
109 | | - toJSON(message: Timestamp): unknown; |
110 | | -}; |
111 | | -type Builtin = Date | Function | Uint8Array | string | number | undefined; |
112 | | -export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends { |
113 | | - $case: string; |
114 | | -} ? { |
115 | | - [K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>; |
116 | | -} & { |
117 | | - $case: T['$case']; |
118 | | -} : T extends {} ? { |
119 | | - [K in keyof T]?: DeepPartial<T[K]>; |
120 | | -} : Partial<T>; |
121 | | -export {}; |
| 1 | +import { Writer, Reader } from 'protobufjs/minimal'; |
| 2 | +/** |
| 3 | + * A Timestamp represents a point in time independent of any time zone or local |
| 4 | + * calendar, encoded as a count of seconds and fractions of seconds at |
| 5 | + * nanosecond resolution. The count is relative to an epoch at UTC midnight on |
| 6 | + * January 1, 1970, in the proleptic Gregorian calendar which extends the |
| 7 | + * Gregorian calendar backwards to year one. |
| 8 | + * |
| 9 | + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap |
| 10 | + * second table is needed for interpretation, using a [24-hour linear |
| 11 | + * smear](https://developers.google.com/time/smear). |
| 12 | + * |
| 13 | + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By |
| 14 | + * restricting to that range, we ensure that we can convert to and from [RFC |
| 15 | + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. |
| 16 | + * |
| 17 | + * # Examples |
| 18 | + * |
| 19 | + * Example 1: Compute Timestamp from POSIX `time()`. |
| 20 | + * |
| 21 | + * Timestamp timestamp; |
| 22 | + * timestamp.set_seconds(time(NULL)); |
| 23 | + * timestamp.set_nanos(0); |
| 24 | + * |
| 25 | + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. |
| 26 | + * |
| 27 | + * struct timeval tv; |
| 28 | + * gettimeofday(&tv, NULL); |
| 29 | + * |
| 30 | + * Timestamp timestamp; |
| 31 | + * timestamp.set_seconds(tv.tv_sec); |
| 32 | + * timestamp.set_nanos(tv.tv_usec * 1000); |
| 33 | + * |
| 34 | + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. |
| 35 | + * |
| 36 | + * FILETIME ft; |
| 37 | + * GetSystemTimeAsFileTime(&ft); |
| 38 | + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; |
| 39 | + * |
| 40 | + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z |
| 41 | + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. |
| 42 | + * Timestamp timestamp; |
| 43 | + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); |
| 44 | + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); |
| 45 | + * |
| 46 | + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. |
| 47 | + * |
| 48 | + * long millis = System.currentTimeMillis(); |
| 49 | + * |
| 50 | + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) |
| 51 | + * .setNanos((int) ((millis % 1000) * 1000000)).build(); |
| 52 | + * |
| 53 | + * |
| 54 | + * Example 5: Compute Timestamp from current time in Python. |
| 55 | + * |
| 56 | + * timestamp = Timestamp() |
| 57 | + * timestamp.GetCurrentTime() |
| 58 | + * |
| 59 | + * # JSON Mapping |
| 60 | + * |
| 61 | + * In JSON format, the Timestamp type is encoded as a string in the |
| 62 | + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the |
| 63 | + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" |
| 64 | + * where {year} is always expressed using four digits while {month}, {day}, |
| 65 | + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional |
| 66 | + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), |
| 67 | + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone |
| 68 | + * is required. A proto3 JSON serializer should always use UTC (as indicated by |
| 69 | + * "Z") when printing the Timestamp type and a proto3 JSON parser should be |
| 70 | + * able to accept both UTC and other timezones (as indicated by an offset). |
| 71 | + * |
| 72 | + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past |
| 73 | + * 01:30 UTC on January 15, 2017. |
| 74 | + * |
| 75 | + * In JavaScript, one can convert a Date object to this format using the |
| 76 | + * standard |
| 77 | + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) |
| 78 | + * method. In Python, a standard `datetime.datetime` object can be converted |
| 79 | + * to this format using |
| 80 | + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with |
| 81 | + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use |
| 82 | + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( |
| 83 | + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D |
| 84 | + * ) to obtain a formatter capable of generating timestamps in this format. |
| 85 | + * |
| 86 | + * |
| 87 | + */ |
| 88 | +export interface Timestamp { |
| 89 | + /** |
| 90 | + * Represents seconds of UTC time since Unix epoch |
| 91 | + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to |
| 92 | + * 9999-12-31T23:59:59Z inclusive. |
| 93 | + */ |
| 94 | + seconds: number; |
| 95 | + /** |
| 96 | + * Non-negative fractions of a second at nanosecond resolution. Negative |
| 97 | + * second values with fractions must still have non-negative nanos values |
| 98 | + * that count forward in time. Must be from 0 to 999,999,999 |
| 99 | + * inclusive. |
| 100 | + */ |
| 101 | + nanos: number; |
| 102 | +} |
| 103 | +export declare const protobufPackage = "google.protobuf"; |
| 104 | +export declare const Timestamp: { |
| 105 | + encode(message: Timestamp, writer?: Writer): Writer; |
| 106 | + decode(input: Uint8Array | Reader, length?: number): Timestamp; |
| 107 | + fromJSON(object: any): Timestamp; |
| 108 | + fromPartial(object: DeepPartial<Timestamp>): Timestamp; |
| 109 | + toJSON(message: Timestamp): unknown; |
| 110 | +}; |
| 111 | +type Builtin = Date | Function | Uint8Array | string | number | undefined; |
| 112 | +export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends { |
| 113 | + $case: string; |
| 114 | +} ? { |
| 115 | + [K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>; |
| 116 | +} & { |
| 117 | + $case: T['$case']; |
| 118 | +} : T extends {} ? { |
| 119 | + [K in keyof T]?: DeepPartial<T[K]>; |
| 120 | +} : Partial<T>; |
| 121 | +export {}; |
0 commit comments