Click or drag to resize

Day Structure

A time-zone-independent representation of a YYYY-MM-DD date.
Inheritance Hierarchy
SystemObject
  SystemValueType
    DegreeDays.TimeDay

Namespace: DegreeDays.Time
Assembly: DegreeDays (in DegreeDays.dll) Version: 1.4
Syntax
public struct Day : IEquatable<Day>, IComparable<Day>

The Day type exposes the following members.

Constructors
 NameDescription
Public methodDay Constructs a Day representing a date with the specified year, month, and day.
Top
Properties
 NameDescription
Public propertyDayOfMonth Gets the number between 1 and 31 (inclusive) indicating the day-of-the-month component of this Day.
Public propertyDayOfWeek Gets the day of the week of this Day.
Public propertyDayOfYear Gets the number between 1 and 366 inclusive (365 for non-leap years) indicating the day of the year of this Day.
Public propertyMonthOfYear Gets the number between 1 (January) and 12 (December) indicating the month-of-the-year component of this Day.
Public propertyYear Gets the number indicating the year component of this Day.
Top
Methods
 NameDescription
Public methodAfter Returns true if this Day is chronologically after the specified comparison Day; false otherwise.
Public methodAsRange Returns a DayRange covering this Day only.
Public methodBefore Returns true if this Day is chronologically before the specified comparison Day; false otherwise.
Public methodCompareTo Compares two Day instances for chronological ordering.
Public methodDaysAfter Returns the number of days that this Day is after the specified comparison Day, which will be negative if this Day comes first chronologically.
Public methodDaysBefore Returns the number of days that this Day is before the specified comparison Day, which will be negative if comparisonDay comes first chronologically.
Public methodEquals(Day) Returns true if other represents the same date as this Day; false otherwise.
Public methodEquals(Object) Returns true if obj is a Day that represents the same date as this Day; false otherwise.
(Overrides ValueTypeEquals(Object))
Public methodStatic memberFromDateTime Returns the Day represented by the specified DateTime.
Public methodStatic memberFromString Parses a string date in ISO YYYY-MM-DD format (the format used by XML schema's date type), or YYYYMMDD format.
Public methodGetHashCode Overridden to ensure consistency with Equals.
(Overrides ValueTypeGetHashCode)
Public methodMinusDays Returns the Day that comes the specified numberOfDays before this Day in the calendar.
Public methodMinusMonths Returns the Day that comes the specified numberOfMonths before this Day in the calendar.
Public methodMinusWeeks Returns the Day that comes the specified numberOfWeeks before this Day in the calendar.
Public methodMinusYears Returns the Day that comes the specified numberOfYears before this Day in the calendar.
Public methodNext Returns the Day that comes immediately after this Day in the calendar. Will happily cross the borders between months and years.
Public methodPlusDays Returns the Day that comes the specified numberOfDays after this Day in the calendar.
Public methodPlusMonths Returns the Day that comes the specified numberOfMonths after this Day in the calendar.
Public methodPlusWeeks Returns the Day that comes the specified numberOfWeeks after this Day in the calendar.
Public methodPlusYears Returns the Day that comes the specified numberOfYears after this Day in the calendar.
Public methodPrevious Returns the Day that comes immediately before this Day in the calendar. Will happily cross the borders between months and years.
Public methodTo(Day) Returns the DayRange covering (inclusively) the days between this Day and firstOrLastDayInRange (which can be before, after, or equal to this Day).
Public methodTo(Int32, Int32, Int32) Returns the DayRange covering (inclusively) the days between this Day and the Day represented by the specified parameters (which can be before, after, or equal to this Day).
Public methodStatic memberTodayInSystemTimeZone Returns the Day representing the current date in the system time-zone.
Public methodStatic memberTodayInUtc Returns the Day representing the current date in the UTC time-zone.
Public methodToNumericString Returns a non-null, non-empty string representation of this Day in YYYYMMDD format.
Public methodToString Returns a non-null, non-empty string representation of this Day in YYYY-MM-DD format.
(Overrides ValueTypeToString)
Public methodStatic memberTryFromString Tries to parse a string date in ISO YYYY-MM-DD format (the format used by XML schema's date type), or YYYYMMDD format. Returns true if it succeeds.
Top
Operators
 NameDescription
Public operatorStatic memberEquality(Day, Day) Determines whether two specified Day instances are equal.
Public operatorStatic memberGreaterThan(Day, Day) Determines whether one specified Day is later than another specified Day.
Public operatorStatic memberGreaterThanOrEqual(Day, Day) Determines whether one specified Day is the same as or later than another specified Day.
Public operatorStatic memberInequality(Day, Day) Determines whether two specified Day instances are not equal.
Public operatorStatic memberLessThan(Day, Day) Determines whether one specified Day is earlier than another specified Day.
Public operatorStatic memberLessThanOrEqual(Day, Day) Determines whether one specified Day is the same as or earlier than another specified Day.
Top
Remarks

Internally this class uses the modern Gregorian calendar for all validation and calculations. The Gregorian calendar was introduced in 1582 but this class applies it to earlier dates as well (so using what is known as the "proleptic Gregorian calendar"). This fits with the ISO 8601 standard and is how System.DateTime package works by default, but not all software systems work this way by default, so bear this in mind if you are working with dates from 1582 or before. You are of course unlikely to find good weather data from that far back, but we mention this just in case you find yourself using this class for other purposes as well!

Thread Safety
Instances of this struct are immutable and safe for use from multiple threads at once.
See Also