public static class TimeExtensionsExtension 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)| Parameter | |
|---|---|
| Name | Description |
timeSpan |
TimeSpanThe time span to convert. |
| Returns | |
|---|---|
| Type | Description |
Duration |
The converted duration. |
ToTimestamp(DateTime)
public static Timestamp ToTimestamp(this DateTime dateTime)| Parameter | |
|---|---|
| Name | Description |
dateTime |
DateTimeThe date and time to convert to a timestamp. |
| Returns | |
|---|---|
| Type | Description |
Timestamp |
The converted timestamp. |
| Exceptions | |
|---|---|
| Type | Description |
ArgumentException |
The |
ToTimestamp(DateTimeOffset)
public static Timestamp ToTimestamp(this DateTimeOffset dateTimeOffset)Converts the given DateTimeOffset to a Timestamp
| Parameter | |
|---|---|
| Name | Description |
dateTimeOffset |
DateTimeOffsetThe 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.