Click or drag to resize

DayMinusYears Method

Returns the Day that comes the specified numberOfYears before this Day in the calendar.

Namespace:  DegreeDays.Time
Assembly:  DegreeDays (in DegreeDays.dll) Version: 1.3
Syntax
public Day MinusYears(
	int numberOfYears
)

Parameters

numberOfYears
Type: SystemInt32
The number of years to subtract from this Day. Can be positive (to go backwards in time), zero, or negative (to go forwards in time).

Return Value

Type: Day
A Day representing the result of the operation.
Exceptions
ExceptionCondition
OverflowExceptionIn the unlikely event of this method requiring a Day with a year less than 1 or greater than 9999.
Remarks

This will always return a valid Day, unless it is outside the range allowed by Day (0001-01-01 to 9999-12-31 inclusive), in which case it will throw an OverflowException.

The MonthOfYear of the returned Day will always be the same as that of this Day. However, the DayOfMonth of the returned Day will change if this Day represents February 29th (in a leap year), and the resulting Day does not fall in a leap year. In this unusual situation the DayOfMonth of the returned Day will be 28 instead of 29, to ensure that it represents a valid date on the Gregorian calendar. For example:

  • 2020-02-29 minus 1 year would give a result of 2019-02-28 (because 2019 is not a leap year like 2020 is).
  • 2020-02-29 minus 4 years would give a result of 2016-02-29 (because 2016 is a leap year, like 2020).

Day is immutable, so calling this method will not change this Day.

See Also