Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/google/protobuf/duration.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/durationpb";
0037 option java_package = "com.google.protobuf";
0038 option java_outer_classname = "DurationProto";
0039 option java_multiple_files = true;
0040 option objc_class_prefix = "GPB";
0041 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
0042 
0043 // A Duration represents a signed, fixed-length span of time represented
0044 // as a count of seconds and fractions of seconds at nanosecond
0045 // resolution. It is independent of any calendar and concepts like "day"
0046 // or "month". It is related to Timestamp in that the difference between
0047 // two Timestamp values is a Duration and it can be added or subtracted
0048 // from a Timestamp. Range is approximately +-10,000 years.
0049 //
0050 // # Examples
0051 //
0052 // Example 1: Compute Duration from two Timestamps in pseudo code.
0053 //
0054 //     Timestamp start = ...;
0055 //     Timestamp end = ...;
0056 //     Duration duration = ...;
0057 //
0058 //     duration.seconds = end.seconds - start.seconds;
0059 //     duration.nanos = end.nanos - start.nanos;
0060 //
0061 //     if (duration.seconds < 0 && duration.nanos > 0) {
0062 //       duration.seconds += 1;
0063 //       duration.nanos -= 1000000000;
0064 //     } else if (duration.seconds > 0 && duration.nanos < 0) {
0065 //       duration.seconds -= 1;
0066 //       duration.nanos += 1000000000;
0067 //     }
0068 //
0069 // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
0070 //
0071 //     Timestamp start = ...;
0072 //     Duration duration = ...;
0073 //     Timestamp end = ...;
0074 //
0075 //     end.seconds = start.seconds + duration.seconds;
0076 //     end.nanos = start.nanos + duration.nanos;
0077 //
0078 //     if (end.nanos < 0) {
0079 //       end.seconds -= 1;
0080 //       end.nanos += 1000000000;
0081 //     } else if (end.nanos >= 1000000000) {
0082 //       end.seconds += 1;
0083 //       end.nanos -= 1000000000;
0084 //     }
0085 //
0086 // Example 3: Compute Duration from datetime.timedelta in Python.
0087 //
0088 //     td = datetime.timedelta(days=3, minutes=10)
0089 //     duration = Duration()
0090 //     duration.FromTimedelta(td)
0091 //
0092 // # JSON Mapping
0093 //
0094 // In JSON format, the Duration type is encoded as a string rather than an
0095 // object, where the string ends in the suffix "s" (indicating seconds) and
0096 // is preceded by the number of seconds, with nanoseconds expressed as
0097 // fractional seconds. For example, 3 seconds with 0 nanoseconds should be
0098 // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
0099 // be expressed in JSON format as "3.000000001s", and 3 seconds and 1
0100 // microsecond should be expressed in JSON format as "3.000001s".
0101 //
0102 message Duration {
0103   // Signed seconds of the span of time. Must be from -315,576,000,000
0104   // to +315,576,000,000 inclusive. Note: these bounds are computed from:
0105   // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
0106   int64 seconds = 1;
0107 
0108   // Signed fractions of a second at nanosecond resolution of the span
0109   // of time. Durations less than one second are represented with a 0
0110   // `seconds` field and a positive or negative `nanos` field. For durations
0111   // of one second or more, a non-zero value for the `nanos` field must be
0112   // of the same sign as the `seconds` field. Must be from -999,999,999
0113   // to +999,999,999 inclusive.
0114   int32 nanos = 2;
0115 }