Warning, /include/google/protobuf/timestamp.proto is written in an unsupported language. File is not indexed.
0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc. All rights reserved.
0003 // https://developers.google.com/protocol-buffers/
0004 //
0005 // Redistribution and use in source and binary forms, with or without
0006 // modification, are permitted provided that the following conditions are
0007 // met:
0008 //
0009 // * Redistributions of source code must retain the above copyright
0010 // notice, this list of conditions and the following disclaimer.
0011 // * Redistributions in binary form must reproduce the above
0012 // copyright notice, this list of conditions and the following disclaimer
0013 // in the documentation and/or other materials provided with the
0014 // distribution.
0015 // * Neither the name of Google Inc. nor the names of its
0016 // contributors may be used to endorse or promote products derived from
0017 // this software without specific prior written permission.
0018 //
0019 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0020 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0021 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0022 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0023 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0025 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0026 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0027 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0028 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0029 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0030
0031 syntax = "proto3";
0032
0033 package google.protobuf;
0034
0035 option cc_enable_arenas = true;
0036 option go_package = "google.golang.org/protobuf/types/known/timestamppb";
0037 option java_package = "com.google.protobuf";
0038 option java_outer_classname = "TimestampProto";
0039 option java_multiple_files = true;
0040 option objc_class_prefix = "GPB";
0041 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
0042
0043 // A Timestamp represents a point in time independent of any time zone or local
0044 // calendar, encoded as a count of seconds and fractions of seconds at
0045 // nanosecond resolution. The count is relative to an epoch at UTC midnight on
0046 // January 1, 1970, in the proleptic Gregorian calendar which extends the
0047 // Gregorian calendar backwards to year one.
0048 //
0049 // All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
0050 // second table is needed for interpretation, using a [24-hour linear
0051 // smear](https://developers.google.com/time/smear).
0052 //
0053 // The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
0054 // restricting to that range, we ensure that we can convert to and from [RFC
0055 // 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
0056 //
0057 // # Examples
0058 //
0059 // Example 1: Compute Timestamp from POSIX `time()`.
0060 //
0061 // Timestamp timestamp;
0062 // timestamp.set_seconds(time(NULL));
0063 // timestamp.set_nanos(0);
0064 //
0065 // Example 2: Compute Timestamp from POSIX `gettimeofday()`.
0066 //
0067 // struct timeval tv;
0068 // gettimeofday(&tv, NULL);
0069 //
0070 // Timestamp timestamp;
0071 // timestamp.set_seconds(tv.tv_sec);
0072 // timestamp.set_nanos(tv.tv_usec * 1000);
0073 //
0074 // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
0075 //
0076 // FILETIME ft;
0077 // GetSystemTimeAsFileTime(&ft);
0078 // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
0079 //
0080 // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
0081 // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
0082 // Timestamp timestamp;
0083 // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
0084 // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
0085 //
0086 // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
0087 //
0088 // long millis = System.currentTimeMillis();
0089 //
0090 // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
0091 // .setNanos((int) ((millis % 1000) * 1000000)).build();
0092 //
0093 // Example 5: Compute Timestamp from Java `Instant.now()`.
0094 //
0095 // Instant now = Instant.now();
0096 //
0097 // Timestamp timestamp =
0098 // Timestamp.newBuilder().setSeconds(now.getEpochSecond())
0099 // .setNanos(now.getNano()).build();
0100 //
0101 // Example 6: Compute Timestamp from current time in Python.
0102 //
0103 // timestamp = Timestamp()
0104 // timestamp.GetCurrentTime()
0105 //
0106 // # JSON Mapping
0107 //
0108 // In JSON format, the Timestamp type is encoded as a string in the
0109 // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
0110 // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
0111 // where {year} is always expressed using four digits while {month}, {day},
0112 // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
0113 // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
0114 // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
0115 // is required. A proto3 JSON serializer should always use UTC (as indicated by
0116 // "Z") when printing the Timestamp type and a proto3 JSON parser should be
0117 // able to accept both UTC and other timezones (as indicated by an offset).
0118 //
0119 // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
0120 // 01:30 UTC on January 15, 2017.
0121 //
0122 // In JavaScript, one can convert a Date object to this format using the
0123 // standard
0124 // [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
0125 // method. In Python, a standard `datetime.datetime` object can be converted
0126 // to this format using
0127 // [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
0128 // the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
0129 // the Joda Time's [`ISODateTimeFormat.dateTime()`](
0130 // http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
0131 // ) to obtain a formatter capable of generating timestamps in this format.
0132 //
0133 message Timestamp {
0134 // Represents seconds of UTC time since Unix epoch
0135 // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
0136 // 9999-12-31T23:59:59Z inclusive.
0137 int64 seconds = 1;
0138
0139 // Non-negative fractions of a second at nanosecond resolution. Negative
0140 // second values with fractions must still have non-negative nanos values
0141 // that count forward in time. Must be from 0 to 999,999,999
0142 // inclusive.
0143 int32 nanos = 2;
0144 }