TimeOnly Struct

Definition

Represents a time of day, as would be read from a clock, within the range 00:00:00 to 23:59:59.9999999.

public value class TimeOnly : IComparable, IComparable<TimeOnly>, IEquatable<TimeOnly>, ISpanFormattable
public struct TimeOnly : IComparable, IComparable<TimeOnly>, IEquatable<TimeOnly>, ISpanFormattable
type TimeOnly = struct
    interface ISpanFormattable
    interface IFormattable
Public Structure TimeOnly
Implements IComparable, IComparable(Of TimeOnly), IEquatable(Of TimeOnly), ISpanFormattable
Inheritance
TimeOnly
Implements

Constructors

TimeOnly(Int32, Int32)

Initializes a new instance of the TimeOnly structure to the specified hour and the minute.

TimeOnly(Int32, Int32, Int32)

Initializes a new instance of the TimeOnly structure to the specified hour, minute, and second.

TimeOnly(Int32, Int32, Int32, Int32)

Initializes a new instance of the TimeOnly structure to the specified hour, minute, second, and millisecond.

TimeOnly(Int64)

Initializes a new instance of the TimeOnly structure using a specified number of ticks.

Properties

Hour

Gets the hour component of the time represented by this instance.

MaxValue

Represents the largest possible value of TimeOnly.

Millisecond

Gets the millisecond component of the time represented by this instance.

Minute

Gets the minute component of the time represented by this instance.

MinValue

Represents the smallest possible value of TimeOnly.

Second

Gets the seconds component of the time represented by this instance.

Ticks

Gets the number of ticks that represent the time of this instance.

Methods

Add(TimeSpan)

Returns a new TimeOnly that adds the value of the specified time span to the value of this instance.

Add(TimeSpan, Int32)

Returns a new TimeOnly that adds the value of the specified time span to the value of this instance. If the result wraps past the end of the day, this method will return the number of excess days as an out parameter.

AddHours(Double)

Returns a new TimeOnly that adds the specified number of hours to the value of this instance.

AddHours(Double, Int32)

Returns a new TimeOnly that adds the specified number of hours to the value of this instance. If the result wraps past the end of the day, this method will return the number of excess days as an out parameter.

AddMinutes(Double)

Returns a new TimeOnly that adds the specified number of minutes to the value of this instance.

AddMinutes(Double, Int32)

Returns a new TimeOnly that adds the specified number of minutes to the value of this instance. If the result wraps past the end of the day, this method will return the number of excess days as an out parameter.

CompareTo(Object)

Compares the value of this instance to a specified object that contains a specified TimeOnly value, and returns an integer that indicates whether this instance is earlier than, the same as, or later than the specified TimeOnly value.

CompareTo(TimeOnly)

Compares the value of this instance to a specified TimeOnly value and indicates whether this instance is earlier than, the same as, or later than the specified TimeOnly value.

Equals(Object)

Returns a value indicating whether this instance is equal to a specified object.

Equals(TimeOnly)

Returns a value indicating whether the value of this instance is equal to the value of the specified TimeOnly instance.

FromDateTime(DateTime)

Constructs a TimeOnly object from a DateTime representing the time of the day in this DateTime object.

FromTimeSpan(TimeSpan)

Constructs a TimeOnly object from a time span representing the time elapsed since midnight.

GetHashCode()

Returns the hash code for this instance.

IsBetween(TimeOnly, TimeOnly)

Determines if a time falls within the range provided. Supports both "normal" ranges such as 10:00-12:00, and ranges that span midnight such as 23:00-01:00.

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

Converts a memory span that contains string representation of a time to its TimeOnly equivalent by using culture-specific format information and a formatting style.

Parse(String)

Converts the string representation of a time to its TimeOnly equivalent by using the conventions of the current culture.

Parse(String, IFormatProvider, DateTimeStyles)

Converts the string representation of a time to its TimeOnly equivalent by using culture-specific format information and a formatting style.

ParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly or an exception is thrown.

ParseExact(ReadOnlySpan<Char>, String[])

Converts the specified span to its TimeOnly equivalent using the specified array of formats. The format of the string representation must match at least one of the specified formats exactly or an exception is thrown.

ParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match at least one of the specified formats exactly or an exception is thrown.

ParseExact(String, String)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified format. The format of the string representation must match the specified format exactly or an exception is thrown.

ParseExact(String, String, IFormatProvider, DateTimeStyles)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly or an exception is thrown.

ParseExact(String, String[])

Converts the specified span to a TimeOnly equivalent using the specified array of formats. The format of the string representation must match at least one of the specified formats exactly or an exception is thrown.

ParseExact(String, String[], IFormatProvider, DateTimeStyles)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information, and style. The format of the string representation must match at least one of the specified formats exactly or an exception is thrown.

ToLongTimeString()

Converts the value of the current TimeOnly instance to its equivalent long date string representation.

ToShortTimeString()

Converts the current TimeOnly instance to its equivalent short time string representation.

ToString()

Converts the current TimeOnly instance to its equivalent short time string representation using the formatting conventions of the current culture.

ToString(IFormatProvider)

Converts the value of the current TimeOnly instance to its equivalent string representation using the specified culture-specific format information.

ToString(String)

Converts the current TimeOnly instance to its equivalent string representation using the specified format and the formatting conventions of the current culture.

ToString(String, IFormatProvider)

Converts the value of the current TimeOnly instance to its equivalent string representation using the specified culture-specific format information.

ToTimeSpan()

Convert the current TimeOnly instance to a TimeSpan object.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Tries to format the value of the current TimeOnly instance into the provided span of characters.

TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

TryParse(ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParse(String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

TryParse(String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified char span of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, String[], TimeOnly)

Converts the specified char span of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String[], IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified string of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String[], TimeOnly)

Converts the specified string of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

Operators

Equality(TimeOnly, TimeOnly)

Determines whether two specified instances of TimeOnlyare equal.

GreaterThan(TimeOnly, TimeOnly)

Determines whether one specified TimeOnly is later than another specified TimeOnly.

GreaterThanOrEqual(TimeOnly, TimeOnly)

Determines whether one specified TimeOnly represents a time that is the same as or later than another specified TimeOnly.

Inequality(TimeOnly, TimeOnly)

Determines whether two specified instances of TimeOnly are not equal.

LessThan(TimeOnly, TimeOnly)

Determines whether one specified TimeOnly is earlier than another specified TimeOnly.

LessThanOrEqual(TimeOnly, TimeOnly)

Determines whether one specified TimeOnly represents a time that is the same as or earlier than another specified TimeOnly.

Subtraction(TimeOnly, TimeOnly)

Gives the elapsed time between two points on a circular clock, which will always be a positive value.

Applies to