# Date Calculator

This date calculator can be used to add to or subtract from a date or time. In cases where daylight saving time might be relevant, the calculator will provide an alternate time based on whether daylight saving time is in effect.

## Gregorian calendar

The measurement of the date is dependent on the calendar used. Generally, there are two main types of calendar systems: a solar calendar and a lunar calendar. This calculator uses the Gregorian calendar, which is a type of solar calendar. The Gregorian calendar is the most widely used calendar in the world. While some countries may use other types of calendars alongside the Gregorian calendar, such as the Chinese lunar calendar, most use the Gregorian calendar as the primary means for measuring official times. Other calendar types may be used to determine when certain holidays such as Chinese New Year, Ramadan, Rosh Hashanah, and Easter occur, but few other countries use any other calendar type as the official means of measuring the time and date. For this reason, this Date Calculator only measures time using the Gregorian calendar system.

Solar calendars, like the Gregorian calendar, are based on the position of the Sun relative to the stars observed from the Earth. The time that it takes the Sun to return to the same position in the sky (such as above Earth), is referred to as a solar year. This is the basis of the measurement of time that most people are accustomed to. A solar year is comprised of 365.24219 days that are broken up into 12 months, each of which have 28-31 days:

Month | Numeric value | # of days |
---|---|---|

January | 1 | 31 |

February | 2 | 28 (29 on leap year) |

March | 3 | 31 |

April | 4 | 30 |

May | 5 | 31 |

June | 6 | 30 |

July | 7 | 31 |

August | 8 | 31 |

September | 9 | 30 |

October | 10 | 31 |

November | 11 | 30 |

December | 12 | 31 |

Leap years are years that contain one additional day that occurs in February; they occur in order to keep the calendar synchronized with the solar year, since a common year has 365 days, but a solar year has 365.24219 days. Leap years occur on years that are an integer multiple of 4, with the exception of years that are evenly divisible by 100 but not 400. This calculator takes leap years into account.

## Adding and subtracting dates

Adding and subtracting from a date takes all of the above into account. Adding years to a date is straightforward; simply add the number of years to the starting year. For example, if the year is 1905 and 27 years are added to that:

1905 + 27 = 1932

The end year is therefore 1932. Similarly, adding a given number of days is relatively straightforward as long as you know the number of days in each month. When adding days, determine the number of days left in the starting month. For example, if the starting date is March 26:

31 - 26 = 5

Thus, there are 5 days left in March. Then, if we want to add 17 days to March 26, we know that there are 5 days left, so subtract 5 from 17 to find out what day of the month it will be in the month of April:

17 - 5 = 12

Thus, 17 days after March 26^{th} will be April 12^{th}. This is the basis for calculating the number of days. Adding and subtracting days can get more complicated if the number of days being added spans a leap year. For example, 2020 was a leap year, so if we add 365 days (1 year) to March 26^{th} 2019, the date will be March 25^{th} 2020 since there is an extra day in February 2022. On the other hand, if we then add another 365 days to March 25^{th}, 2020, the date will be March 25^{th}, 2021. This is because the month of February 2020 was already passed (so there is no longer an extra day to account for), and 2021 is not a leap year.

In contrast to years and days, there are two ways to consider adding or subtracting months. This is because there are a different number of days in each month, so we need to define what 1 month is in the context of the calculator. One way to add a month takes into account the current day of the month. For example, February 28^{th} on a common year is the last day of the month of February. If we consider adding 1 month to the last day of February, we could think of the result as being the last day of March, or March 31^{st}. This is not the method used by this calculator.

The method used by this calculator ignores the difference in the number of days in each month. This means that when adding months, we only consider the numeric representation of the month, and add the input value. For example, March is the third month of the year, with a numeric value of 3. Adding 1 month on this calculator simply means adding 1 to 3:

3 + 1 = 4

4 is the numeric representation of the month of April. With this method, when adding 1 month to February 28^{th}, the result is March 28^{th} instead of March 31^{th}. If the number of months being added makes the result larger than 12, divide by 12 with remainder. The remainder is the numeric representation of the month, and the dividend is the number of years that must be added to the year. For example, if we add 65 months to the month of March, we get:

3 + 65 = 68

Dividing 68 by 12 with remainder yields:

68 ÷ 12 = 5 R8

The remainder of 8 is the numeric representation of the month of August, so adding 65 months to March makes it August. Taking the number of years elapsed into consideration, if the year was 2022, then we would also add 5 to the year to make it August of 2027. Note that depending on the number of months left over and the starting month, there are cases where an additional year would need to be added, since even though the months added don't comprise a full year, the remaining months in the year relative to the starting month may carry us over to the next year.

Subtracting years, months, and days is quite similar to adding them. For example, to subtract 25 years from 2022:

2022 - 25 = 1997

When subtracting days, we again need to take into account the number of days in a month. To subtract 30 days from March 26^{th}, 2022, we note that February has 28 days in a common year. Thus, after subtracting 26, the remaining 4 days are subtracted from February 28^{th} such that the final date is February 24^{th}, 2022.

When subtracting months, the method is slightly different than for addition, but the concept is the same, and the goal is to find a numeric representation of the month. For example, subtracting 10 months from the month of March yields:

3 - 10 = -7

To convert this into a numeric representation of a month, take the absolute value of the result and subtract it from 12:

12 - 7 = 5

Thus, subtracting 10 months from March will make it May. The process is similar when larger numbers of months are subtracted. For example, subtracting 68 months from March yields:

3 - 68 = -65

To find the numeric representation of the month, take the absolute value of the result and divide by 12 with remainder:

65 ÷ 12 = 5 R5

Then, subtract the remainder from 12 to find the numeric representation of the month:

12 - 5 = 7

Thus, subtracting 68 months from March will make it July. Note that it is also necessary to subtract 5 years and 1 additional year, since we began in the month of March, but still needed to subtract an additional 8 months. This makes the final date July 2016.

## Daylight saving time

Another factor that this calculator takes into consideration is daylight saving time; this is only relevant when selecting the "include the time" checkbox. Refer to the Time Calculator for more information on how to add or subtract time.

Daylight saving time is a practice that is observed in certain countries or regions around the world, particularly in North America and Europe. It was originally implemented on the basis of making better use of daylight hours in agrarian societies. The practice involves advancing the clock by 1 hour in the summer months such that darkness will occur at a later clock time. This has the effect of people waking earlier, completing their work day sooner, and having an extra hour of daylight after their work day. The clocks are then set back one hour in autumn to return to standard time. Although these benefits are arguably not as relevant in today's industrialized society, daylight saving time is still widely used in many parts of the world.

Daylight saving time is relevant to this calculator when the user is interested in including clock time. When the user selects inputs such that the addition or subtraction of time spans a change to daylight saving time or back to standard time, the calculator will provide a notification; if the region the user is in observes daylight saving time, the correct time in the region will be reflected in this notification rather than the original result of the calculator; if the region the user is in does not observe daylight saving time, then the original result of the calculator is the correct time in the region.