diff options
Diffstat (limited to 'csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs')
-rw-r--r-- | csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs index 39251e2e..cc2dfd26 100644 --- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs +++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs @@ -48,12 +48,16 @@ namespace Google.Protobuf.WellKnownTypes { /// or "month". It is related to Timestamp in that the difference between /// two Timestamp values is a Duration and it can be added or subtracted /// from a Timestamp. Range is approximately +-10,000 years. + /// /// Example 1: Compute Duration from two Timestamps in pseudo code. + /// /// Timestamp start = ...; /// Timestamp end = ...; /// Duration duration = ...; + /// /// duration.seconds = end.seconds - start.seconds; /// duration.nanos = end.nanos - start.nanos; + /// /// if (duration.seconds < 0 && duration.nanos > 0) { /// duration.seconds += 1; /// duration.nanos -= 1000000000; @@ -61,12 +65,16 @@ namespace Google.Protobuf.WellKnownTypes { /// duration.seconds -= 1; /// duration.nanos += 1000000000; /// } + /// /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + /// /// Timestamp start = ...; /// Duration duration = ...; /// Timestamp end = ...; + /// /// end.seconds = start.seconds + duration.seconds; /// end.nanos = start.nanos + duration.nanos; + /// /// if (end.nanos < 0) { /// end.seconds -= 1; /// end.nanos += 1000000000; |