Time

Field: static readonly Time MinValue

It is the smallest time value (000000).


Field: static readonly Time MaxValue

It is the greatest time value (235959).


Method: static Time Parse(String)

Converts time information of string type to Time object.

    Time time = Time.Parse("154512"); //15:45:12
Parameter Name Description
timeString Time object in string type

Error Type: FormatException (This error is thrown if it can not be parse according to hhmmss format and TimeSpan type. )


Constructor(Int32)

Creates a Time object with time information.

Parameter Name Description
hour int type time information

Constructor(Int32, Int32)

Creates Time object with hour and minute information.

Parameter Name Description
hour int type hour information
minute int type minute information

Property: TimeSpan Value

Returns time information of type TimeSpan.


Method: TimeSpan ToTimeSpan()

Returns time information of type TimeSpan.


Method: string ToString()

Returns the value in string type and hhmmss format.

    new Time(15,45,12).ToString(); //154512

Method: int CompareTo(Object)

If the value of the given object is greater than the value of the Time data, it returns -1, 0 if it is equal, and 1 if it is smaller. The given object must be of type Time.

    new Time(22, 13, 19).CompareTo(new Time(22, 13, 20)) < 0); //true
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 20)) == 0); //true
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 19)) > 0); //true

    new Time(22, 13, 19).CompareTo(new Time(22, 13, 20)) >= 0 //false
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 20)) != 0 //false
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 19)) <= 0 //false
Parameter Name Description
obj Object to be compared

Error Type: ArgumentException (This error is thrown if the value is not Money type.)


Method: int CompareTo(Time)

If the value of the given object is greater than the value of the Time data, it returns -1, 0 if it is equal, and 1 if it is smaller.

    new Time(22, 13, 19).CompareTo(new Time(22, 13, 20)) < 0); //true
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 20)) == 0); //true
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 19)) > 0); //true

    new Time(22, 13, 19).CompareTo(new Time(22, 13, 20)) >= 0 //false
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 20)) != 0 //false
    new Time(22, 13, 20).CompareTo(new Time(22, 13, 19)) <= 0 //false
Parameter Name Description
other Money object to compare

Method: bool Equals(Object)

Returns true if the given object has the same value as the Time object and the data, false otherwise.

Parameter Name Description
obj Object to be compared

Method: bool Equals(Time)

Returns true if the given Time object has the same value as the data, false otherwise.

Parameter Name Description
other The object of type Time to be compared

Extension Method: static Time ToTime(DateTime)

Creates Time object with hour, minute and second information of object of type DateTime.

    new Time(22, 13, 20) == new DateTime(2014, 4, 5, 22, 13, 20).ToTime(); //true
Parameter Name Description
source Date and time object in DateTime type

Extension Method: static Time ToTime(TimeSpan)

Creates Time object with hour, minute and second information of object of type TimeSpan.

    new Time(22, 13, 20) == new TimeSpan(22, 13, 20).ToTime(); //true
Parameter Name Description
source Time object type TimeSpan

Extension Method: static Time ToTime(Int64)

Creates Time object with hour, minute and second information of object of type long.

    ((long)18012202000000).ToTime(); //20:20:20
Parameter Name Description
source long object type TimeSpan