public static class TimeExtensions : object
Extension methods on BCL time-related types, converting to protobuf types.
Namespace
Google.Protobuf.WellKnownTypesAssembly
Google.Protobuf.dll
Methods
ToDuration(TimeSpan)
public static Duration ToDuration(this TimeSpan timeSpan)
Converts the given to a Duration.
Parameter | |
---|---|
Name | Description |
timeSpan | TimeSpan The time span to convert. |
Returns | |
---|---|
Type | Description |
Duration | The converted duration. |
ToTimestamp(DateTime)
public static Timestamp ToTimestamp(this DateTime dateTime)
Converts the given to a Timestamp.
Parameter | |
---|---|
Name | Description |
dateTime | DateTime The date and time to convert to a timestamp. |
Returns | |
---|---|
Type | Description |
Timestamp | The converted timestamp. |
ToTimestamp(DateTimeOffset)
public static Timestamp ToTimestamp(this DateTimeOffset dateTimeOffset)
Converts the given to a Timestamp
Parameter | |
---|---|
Name | Description |
dateTimeOffset | DateTimeOffset The date and time (with UTC offset) to convert to a timestamp. |
Returns | |
---|---|
Type | Description |
Timestamp | The converted timestamp. |
The offset is taken into consideration when converting the value (so the same instant in time
is represented) but is not a separate part of the resulting value. In other words, there is no
roundtrip operation to retrieve the original DateTimeOffset
.