Struct TimeOfDay
Represents the time offset since the beginning of the day.
Namespace: Neon.Time
Assembly: Neon.Common.dll
Syntax
public struct TimeOfDay
Constructors
TimeOfDay(DateTime)
Constructs a time of day offset by stripping the date portion from the parameter passed.
Declaration
public TimeOfDay(DateTime date)
Parameters
Type | Name | Description |
---|---|---|
DateTime | date | The source date time. |
TimeOfDay(int, int)
Constructs a time of day offset from hours and minutes.
Declaration
public TimeOfDay(int hours, int minutes)
Parameters
Type | Name | Description |
---|---|---|
int | hours | The hours. |
int | minutes | The minutes. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the specified offset is negative or >= 24 hours. |
TimeOfDay(int, int, int)
Constructs a time of day offset from hours, minutes, and seconds.
Declaration
public TimeOfDay(int hours, int minutes, int seconds)
Parameters
Type | Name | Description |
---|---|---|
int | hours | The hours. |
int | minutes | The minutes. |
int | seconds | The seconds. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the specified offset is negative or >= 24 hours. |
TimeOfDay(string)
Constructs a time of day offset by parsing a string of the form HH:MM or HH:MM:SS.
Declaration
public TimeOfDay(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | The input string. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the string passed does not represent a valid time of day offset. |
TimeOfDay(TimeSpan)
Constructs a time of day offset from a TimeSpan.
Declaration
public TimeOfDay(TimeSpan offset)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | offset | The time offset from the beginning of the day. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the specified offset is negative or >= 24 hours. |
Properties
Hour
Returns the hours part of the time offset.
Declaration
public int Hour { get; }
Property Value
Type | Description |
---|---|
int |
Minute
Returns the minutes part of the time offset.
Declaration
public int Minute { get; }
Property Value
Type | Description |
---|---|
int |
Second
Returns the seconds part of the time offset.
Declaration
public int Second { get; }
Property Value
Type | Description |
---|---|
int |
TimeSpan
Returns the offset as a TimeSpan.
Declaration
public TimeSpan TimeSpan { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Methods
ToString()
Renders the time of day value as a string formatted as HH:MM:SS.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The formatted string. |
Overrides
TryParse(string, out TimeOfDay)
Attempts to parse a string of the form HH:MM or HH:MM:SS into a time of day offset.
Declaration
public static bool TryParse(string value, out TimeOfDay timeOfDay)
Parameters
Type | Name | Description |
---|---|---|
string | value | The string to be parsed. |
TimeOfDay | timeOfDay | Returns as the parsed time of day on success. |
Returns
Type | Description |
---|---|
bool |
|