Struct DateSpan
- Namespace
- Cuemon
- Assembly
- Cuemon.Core.dll
public readonly struct DateSpan : IEquatable<DateSpan>
- Implements
Constructors
DateSpan(DateTime)
public DateSpan(DateTime start)
Parameters
DateSpan(DateTime, DateTime)
Initializes a new instance of the DateSpan structure with a default Cuemon.DateSpan._calendar value from the InvariantCulture class.
public DateSpan(DateTime start, DateTime end)
Parameters
DateSpan(DateTime, DateTime, Calendar)
Initializes a new instance of the DateSpan structure.
public DateSpan(DateTime start, DateTime end, Calendar calendar)
Parameters
Properties
Days
Gets the number of days represented by the current DateSpan structure.
public readonly int Days { get; }
Property Value
Hours
Gets the number of hours represented by the current DateSpan structure.
public readonly int Hours { get; }
Property Value
Milliseconds
Gets the number of milliseconds represented by the current DateSpan structure.
public readonly int Milliseconds { get; }
Property Value
Minutes
Gets the number of minutes represented by the current DateSpan structure.
public readonly int Minutes { get; }
Property Value
Months
Gets the number of months represented by the current DateSpan structure.
public readonly int Months { get; }
Property Value
Seconds
Gets the number of seconds represented by the current DateSpan structure.
public readonly int Seconds { get; }
Property Value
Ticks
Gets the number of ticks represented by the current DateSpan structure.
public readonly long Ticks { get; }
Property Value
TotalDays
Gets the total number of days represented by the current DateSpan structure.
public readonly double TotalDays { get; }
Property Value
TotalHours
Gets the total number of hours represented by the current DateSpan structure.
public readonly double TotalHours { get; }
Property Value
TotalMilliseconds
Gets the total number of milliseconds represented by the current DateSpan structure.
public readonly double TotalMilliseconds { get; }
Property Value
TotalMinutes
Gets the total number of minutes represented by the current DateSpan structure.
public readonly double TotalMinutes { get; }
Property Value
TotalMonths
Gets the total number of months represented by the current DateSpan structure.
public readonly double TotalMonths { get; }
Property Value
TotalSeconds
Gets the total number of seconds represented by the current DateSpan structure.
public readonly double TotalSeconds { get; }
Property Value
TotalYears
Gets the total number of years represented by the current DateSpan structure.
public readonly double TotalYears { get; }
Property Value
Years
Gets the number of years represented by the current DateSpan structure.
public readonly int Years { get; }
Property Value
Methods
Equals(DateSpan)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(DateSpan other)
Parameters
other
DateSpanAn object to compare with this object.
Returns
- Boolean
true
if the current object is equal to the other parameter; otherwise,false
.
Equals(Object)
Determines whether the specified Object is equal to this instance.
public override readonly bool Equals(object obj)
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- Int32
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
GetWeeks()
Calculates the number of weeks represented by the current DateSpan structure.
public readonly int GetWeeks()
Returns
Parse(String)
Constructs a new DateSpan object from a date and time interval specified in a string.
public static DateSpan Parse(string start)
Parameters
Returns
Parse(String, String)
Constructs a new DateSpan object from a date and time interval specified in a string.
public static DateSpan Parse(string start, string end)
Parameters
start
StringA string that specifies the starting date and time value for the DateSpan interval.
end
StringA string that specifies the ending date and time value for the DateSpan interval.
Returns
Parse(String, String, CultureInfo)
Constructs a new DateSpan object from a date and time interval specified in a string.
public static DateSpan Parse(string start, string end, CultureInfo culture)
Parameters
start
StringA string that specifies the starting date and time value for the DateSpan interval.
end
StringA string that specifies the ending date and time value for the DateSpan interval.
culture
CultureInfoA CultureInfo to resolve a Cuemon.DateSpan._calendar object from.
Returns
ToString()
Converts the value of the current DateSpan object to its equivalent string representation.
public override readonly string ToString()
Returns
Remarks
The returned string has the following format: y*:MM:dd:hh:mm:ss.f*, where y* is the actual calculated years and f* is the actual calculated milliseconds.
Operators
Equality(DateSpan, DateSpan)
Indicates whether two DateSpan instances are equal.
public static bool operator ==(DateSpan dateSpan1, DateSpan dateSpan2)
Parameters
dateSpan1
DateSpanThe first date interval to compare.
dateSpan2
DateSpanThe second date interval to compare.
Returns
- Boolean
true
if the values ofdateSpan1
anddateSpan2
are equal; otherwise, false.
Inequality(DateSpan, DateSpan)
Indicates whether two DateSpan instances are not equal.
public static bool operator !=(DateSpan dateSpan1, DateSpan dateSpan2)
Parameters
dateSpan1
DateSpanThe first date interval to compare.
dateSpan2
DateSpanThe second date interval to compare.
Returns
- Boolean
true
if the values ofdateSpan1
anddateSpan2
are not equal; otherwise, false.