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