Noda Time
Show / Hide Table of Contents

Class NodaExtensions

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
NodaExtensions
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 NodaExtensions

Methods

ToDate(LocalDate)

Converts a Noda Time LocalDate to a Protobuf Date.
Since 1.0.x
Availability netstandard2.0
Declaration
public static Date ToDate(this LocalDate date)
Parameters
Type Name Description
LocalDate date The date to convert.
Returns
Type Description
Date The Protobuf representation.
Remarks
Only dates in the ISO calendar can be converted, and only those in the year range of 1-9999.

ToProtobufDayOfWeek(IsoDayOfWeek)

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

ToProtobufDuration(Duration)

Converts a Noda Time Duration to a Protobuf Duration.
Since 1.0.x
Availability netstandard2.0
Declaration
public static Duration ToProtobufDuration(this Duration duration)
Parameters
Type Name Description
Duration duration The duration to convert. Must not be null.
Returns
Type Description
Duration The Protobuf representation.
Remarks
Noda Time has a wider range of valid durations than Protobuf; durations of more than around 10,000 years (positive or negative) cannot be represented.
Exceptions
Type Condition
ArgumentOutOfRangeException duration represents a duration which is invalid in Duration.

ToTimeOfDay(LocalTime)

Converts a Noda Time LocalTime to a Protobuf TimeOfDay.
Since 1.0.x
Availability netstandard2.0
Declaration
public static TimeOfDay ToTimeOfDay(this LocalTime localTime)
Parameters
Type Name Description
LocalTime localTime The local time.
Returns
Type Description
TimeOfDay The Protobuf representation.
Remarks
Every valid Noda Time local time can be represented in Protobuf without loss of information.

ToTimestamp(Instant)

Converts a Noda Time Instant to a Protobuf Timestamp.
Since 1.0.x
Availability netstandard2.0
Declaration
public static Timestamp ToTimestamp(this Instant instant)
Parameters
Type Name Description
Instant instant The instant to convert.
Returns
Type Description
Timestamp The Protobuf representation.
Remarks
Noda Time has a wider range of valid instants than Protobuf timestamps; instants before 0001-01-01 CE are out of range.
Exceptions
Type Condition
ArgumentOutOfRangeException instant represents an instant which is invalid in Timestamp.
In this article
Back to top Generated by DocFX