Packages

final case class Duration(seconds: Long = 0L, nanos: Int = 0, unknownFields: scalapb.UnknownFieldSet = ...) extends scalapb.GeneratedMessage with Updatable[Duration] with DurationMethods with Product with Serializable

A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" 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.

# Examples

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; } else if (duration.seconds > 0 && duration.nanos < 0) { 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; } else if (end.nanos >= 1000000000) { end.seconds += 1; end.nanos -= 1000000000; }

Example 3: Compute Duration from datetime.timedelta in Python.

td = datetime.timedelta(days=3, minutes=10) duration = Duration() duration.FromTimedelta(td)

# JSON Mapping

In JSON format, the Duration type is encoded as a string rather than an object, where the string ends in the suffix "s" (indicating seconds) and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds. For example, 3 seconds with 0 nanoseconds should be encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should be expressed in JSON format as "3.000000001s", and 3 seconds and 1 microsecond should be expressed in JSON format as "3.000001s".

seconds

Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years

nanos

Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 seconds field and a positive or negative nanos field. For durations of one second or more, a non-zero value for the nanos field must be of the same sign as the seconds field. Must be from -999,999,999 to +999,999,999 inclusive.

Annotations
@SerialVersionUID()
Linear Supertypes
DurationMethods, Updatable[Duration], scalapb.GeneratedMessage, Serializable, Serializable, Product, Equals, AnyRef, scala.Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Duration
  2. DurationMethods
  3. Updatable
  4. GeneratedMessage
  5. Serializable
  6. Serializable
  7. Product
  8. Equals
  9. AnyRef
  10. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Duration(seconds: Long = 0L, nanos: Int = 0, unknownFields: scalapb.UnknownFieldSet = ...)

    seconds

    Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years

    nanos

    Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 seconds field and a positive or negative nanos field. For durations of one second or more, a non-zero value for the nanos field must be of the same sign as the seconds field. Must be from -999,999,999 to +999,999,999 inclusive.

Value Members

  1. final def !=(arg0: scala.Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: scala.Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. final def asJavaDuration: java.time.Duration
    Definition Classes
    DurationMethods
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  7. def companion: Duration.type
    Definition Classes
    DurationGeneratedMessage
  8. def discardUnknownFields: Duration
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. def getField(__field: FieldDescriptor): PValue
    Definition Classes
    DurationGeneratedMessage
  13. def getFieldByNumber(__fieldNumber: Int): scala.Any
    Definition Classes
    DurationGeneratedMessage
  14. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  15. val nanos: Int
    Definition Classes
    DurationDurationMethods
  16. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. val seconds: Long
    Definition Classes
    DurationDurationMethods
  20. def serializedSize: Int
    Definition Classes
    DurationGeneratedMessage
  21. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  22. final def toByteArray: Array[Byte]

    Serializes the message and returns a byte array containing its raw bytes

    Serializes the message and returns a byte array containing its raw bytes

    Definition Classes
    GeneratedMessage
  23. final def toByteString: ByteString

    Serializes the message and returns a ByteString containing its raw bytes

    Serializes the message and returns a ByteString containing its raw bytes

    Definition Classes
    GeneratedMessage
  24. final def toPMessage: PMessage
    Definition Classes
    GeneratedMessage
  25. def toProtoString: String

    Returns a human-readable ASCII format representation of this message.

    Returns a human-readable ASCII format representation of this message.

    The original message can be decoded from this format by using fromAscii on the companion object.

    returns

    human-readable representation of this message.

    Definition Classes
    DurationGeneratedMessage
  26. val unknownFields: scalapb.UnknownFieldSet
  27. def update(ms: (Lens[Duration, Duration]) ⇒ Mutation[Duration]*): Duration
    Definition Classes
    Updatable
  28. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  31. def withNanos(__v: Int): Duration
  32. def withSeconds(__v: Long): Duration
  33. def withUnknownFields(__v: scalapb.UnknownFieldSet): Duration
  34. final def writeDelimitedTo(output: OutputStream): Unit
    Definition Classes
    GeneratedMessage
  35. def writeTo(_output__: CodedOutputStream): Unit

    Serializes the message into the given coded output stream

    Serializes the message into the given coded output stream

    Definition Classes
    DurationGeneratedMessage
  36. final def writeTo(output: OutputStream): Unit

    Serializes the message into the given output stream

    Serializes the message into the given output stream

    Definition Classes
    GeneratedMessage

Inherited from DurationMethods

Inherited from Updatable[Duration]

Inherited from scalapb.GeneratedMessage

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from scala.Any

Ungrouped