Noda Time
Show / Hide Table of Contents

Class ProtobufExtensions

Extension methods on the Google.Protobuf time-related types to convert them to Noda Time types.
Since 1.0.x
Availability netstandard2.0
Inheritance
object
ProtobufExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: NodaTime.Serialization.Protobuf
Assembly: NodaTime.Serialization.Protobuf.dll
Syntax
public static class ProtobufExtensions

Methods

ToInstant(Timestamp)

Converts a Protobuf Timestamp to a Noda Time Instant.
Since 1.0.x
Availability netstandard2.0
Declaration
public static Instant ToInstant(this Timestamp timestamp)
Parameters
Type Name Description
Timestamp timestamp The timestamp to convert. Must not be null.
Returns
Type Description
Instant The Noda Time representation.
Remarks
Every valid Protobuf timestamp can be represented in Noda Time without loss of information.
Exceptions
Type Condition
ArgumentException timestamp represents an invalid timestamp.
ArgumentNullException timestamp is null.

ToIsoDayOfWeek(DayOfWeek)

Converts a Protobuf Google.Type.DayOfWeek to a Noda Time IsoDayOfWeek.
Since 1.0.x
Availability netstandard2.0
Declaration
public static IsoDayOfWeek ToIsoDayOfWeek(this DayOfWeek dayOfWeek)
Parameters
Type Name Description
DayOfWeek dayOfWeek The day-of-week value to convert.
Returns
Type Description
IsoDayOfWeek The Noda Time representation.
Remarks
The Google.Type.DayOfWeek.Unspecified value maps to None.
Exceptions
Type Condition
ArgumentOutOfRangeException dayOfWeek is neither Unspecified nor a valid day-of-week value.

ToLocalDate(Date)

Converts a Protobuf Date to a Noda Time LocalDate.
Since 1.0.x
Availability netstandard2.0
Declaration
public static LocalDate ToLocalDate(this Date date)
Parameters
Type Name Description
Date date The date to convert. Must not be null.
Returns
Type Description
LocalDate
Remarks
The resulting date is always in the ISO calendar. The input date must be completely specified; values with a 0 year, month or day are not supported.

ToLocalTime(TimeOfDay)

Converts a Protobuf TimeOfDay to a Noda Time LocalTime.
Since 1.0.x
Availability netstandard2.0
Declaration
public static LocalTime ToLocalTime(this TimeOfDay timeOfDay)
Parameters
Type Name Description
TimeOfDay timeOfDay The time of day to convert. Must not be null
Returns
Type Description
LocalTime The Noda Time representation.
Exceptions
Type Condition
ArgumentException The time of day is invalid, uses a leap second, or indicates 24:00.

ToNodaDuration(Duration)

Converts a Protobuf Duration to a Noda Time Duration.
Since 1.0.x
Availability netstandard2.0
Declaration
public static Duration ToNodaDuration(this Duration duration)
Parameters
Type Name Description
Duration duration The duration to convert. Must not be null.
Returns
Type Description
Duration The Noda Time representation.
Remarks
Every valid Protobuf duration can be represented in Noda Time without loss of information.
Exceptions
Type Condition
ArgumentException duration represents an invalid duration.
ArgumentNullException duration is null.
In this article
Back to top Generated by DocFX