Struct SwiftTime
Represents a time within a day, accurate to a second. This structure can be logically null.
public struct SwiftTime : IComparable
- Implements
- Inherited Members
Remarks
An unconstructed instance of this structure is considered to have a null value.
Constructors
SwiftTime(DateTime)
Constructs a SwiftTime instance from the time portion of a System.DateTime.
public SwiftTime(DateTime tTime)
Parameters
tTimeDateTimeSystem.DateTime instance that provides the time. Only the Hour, Minute and Second properties from this instance are used.
SwiftTime(int, int, int)
Constructs a SwiftTime instance with the given time.
public SwiftTime(int nHour, int nMinute, int nSecond)
Parameters
nHourintHour in the range from 0 through 23.
nMinuteintMinute in the range from 0 through 59.
nSecondintSecond in the range from 0 through 59.
Exceptions
- ArgumentOutOfRangeException
If any of the arguments is outside the allowed range, then an ArgumentOutOfRangeException will be thrown.
Fields
NullTime
Represents a null time.
public static readonly SwiftTime NullTime
Field Value
Properties
Hour
The hour of this time.
public int Hour { get; set; }
Property Value
- int
This allowed range of this property is 0 through 23.
Exceptions
- ArgumentOutOfRangeException
An attempt to set the hour to a value outside of the allowed range 0 through 23 will cause an ArgumentOutOfRangeException to be thrown.
IsNull
Indicates whether this SwiftTime instance is logically null.
public bool IsNull { get; }
Property Value
Minute
The minute of this time.
public int Minute { get; set; }
Property Value
- int
This allowed range of this property is 0 through 59.
Exceptions
- ArgumentOutOfRangeException
An attempt to set the minute to a value outside of the allowed range 0 through 59 will cause an ArgumentOutOfRangeException to be thrown.
Second
The second of this time.
public int Second { get; set; }
Property Value
- int
This allowed range of this property is 0 through 59.
Exceptions
- ArgumentOutOfRangeException
An attempt to set the second to a value outside of the allowed range 0 through 59 will cause an ArgumentOutOfRangeException to be thrown.
Methods
AddTime(DateTime)
public DateTime AddTime(DateTime tDateTime)
Parameters
tDateTimeDateTime
Returns
CompareTo(object)
Implements IComparable.CompareTo.
public int CompareTo(object obj)
Parameters
objobjectOther SwiftTime to compare to.
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
Parse(string)
Parses a string time.
public static SwiftTime Parse(string sStringTime)
Parameters
sStringTimestringDate to be parsed in one of the following formats: HH:MM:SS, HHMMSS, HH:MM, or HHMM.
Returns
- SwiftTime
Returns a new instance of the SwiftTime class that is initialised with the parsed time. If no seconds have been given, then the Second will be zero.
Exceptions
- ArgumentNullException
If the given string is null, then an ArgumentNullException will be thrown.
- ArgumentException
The given sStringTime does not have a length of 4, 5, 6 or 8 characters.
- FormatException
If the given string is not in one of the acceptable formats, or the hour, minute or second are outside of the allowed range, then a FormatException is thrown.
ToString()
Converts this time to a string in the format HHMMSS.
public override string ToString()
Returns
- string
Returns the converted time.
Remarks
This is an overloaded convenience method that internally just calls ToString(SwiftTimeFormat) requesting the SwiftTimeHHMMSS.
ToString(SwiftTimeFormat)
Converts this time to a string representation in the format specified.
public string ToString(SwiftTimeFormat nTimeFormat)
Parameters
nTimeFormatSwiftTimeFormatSelects the format to be used for the generated time string.
Returns
- string
Returns the converted date.
ToString(bool)
This method is deprecated!
public string ToString(bool fLongFormat)
Parameters
fLongFormatbool
Returns
TryParse(string)
public static SwiftTime TryParse(string sStringTime)
Parameters
sStringTimestring
Returns
Operators
operator ==(SwiftTime, SwiftTime)
public static bool operator ==(SwiftTime lhs, SwiftTime rhs)
Parameters
Returns
operator >(SwiftTime, SwiftTime)
public static bool operator >(SwiftTime lhs, SwiftTime rhs)
Parameters
Returns
operator >=(SwiftTime, SwiftTime)
public static bool operator >=(SwiftTime lhs, SwiftTime rhs)
Parameters
Returns
operator !=(SwiftTime, SwiftTime)
public static bool operator !=(SwiftTime lhs, SwiftTime rhs)
Parameters
Returns
operator <(SwiftTime, SwiftTime)
public static bool operator <(SwiftTime lhs, SwiftTime rhs)
Parameters
Returns
operator <=(SwiftTime, SwiftTime)
public static bool operator <=(SwiftTime lhs, SwiftTime rhs)