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
Inherited Members
Namespace: NodaTime.Serialization.Protobuf
Assembly: NodaTime.Serialization.Protobuf.dll
Syntax
public static class ProtobufExtensions
Methods
ToInstant(Timestamp)
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)
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)
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)
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. |