Gregorian Calendar Most widely used civil calendar. Introduced in October 1582 by Pope Gregory XIII. Based on a 365-day year, with a leap day ($February 29^{th}$) added every four years. Leap Year Rules A year is a leap year if it is divisible by 4. Exception: Years divisible by 100 are NOT leap years. Exception to the Exception: Years divisible by 400 ARE leap years. Examples: 2000: Leap year (divisible by 400) 1900: Not a leap year (divisible by 100, not by 400) 2024: Leap year (divisible by 4) 2023: Not a leap year Months and Days Number of days in each month: Month Days January 31 February 28/29 March 31 April 30 May 31 June 30 July 31 August 31 September 30 October 31 November 30 December 31 Weekdays Cycle There are 7 days in a week. The day of the week advances by 1 for each day passed. A non-leap year has 365 days. $365 \div 7 = 52$ weeks and $1$ day. This means if January 1st of a non-leap year is a Monday, January 1st of the next year will be a Tuesday. A leap year has 366 days. $366 \div 7 = 52$ weeks and $2$ days. This means if January 1st of a leap year is a Monday, January 1st of the next year will be a Wednesday. Julian Day Number A continuous count of days from the beginning of the Julian Period ($January 1, 4713 BCE$). Used in astronomy and for calculating elapsed time between two widely separated dates. Formula (simplified for Gregorian calendar, valid for $AD$ 1582 onwards): $$ JD = D + \lfloor \frac{153M_{adj} + 2}{5} \rfloor + 365Y_{adj} + \lfloor \frac{Y_{adj}}{4} \rfloor - \lfloor \frac{Y_{adj}}{100} \rfloor + \lfloor \frac{Y_{adj}}{400} \rfloor - 32045 $$ Where: $D$ is the day of the month. If $M \le 2$: $M_{adj} = M + 12$, $Y_{adj} = Y - 1$. If $M > 2$: $M_{adj} = M$, $Y_{adj} = Y$. Doomsday Algorithm (for mental calculation) A method to determine the day of the week for any given date. Anchor Day: Know the "Doomsdays" for certain dates each year (e.g., $4/4, 6/6, 8/8, 10/10, 12/12$, and $28/2$ (non-leap) or $29/2$ (leap)). Century Anchor Day: 1700s: Tuesday 1800s: Sunday 1900s: Tuesday 2000s: Tuesday 2100s: Sunday (Pattern repeats every 400 years: $Tuesday \rightarrow Sunday \rightarrow Friday \rightarrow Wednesday \rightarrow Tuesday$) Year Offset: Let $Y$ be the last two digits of the year. $Offset = \lfloor Y/12 \rfloor + (Y \pmod{12}) + \lfloor (Y \pmod{12})/4 \rfloor$ Calculate Doomsday for the Year: $Doomsday = (Century\ Anchor\ Day + Offset) \pmod{7}$ ($0=Sun, 1=Mon, \dots, 6=Sat$) Find Day of Week: Calculate difference from Doomsday to target date. Example: To find the day of week for $July\ 4, 1776$ Century Anchor for 1700s = Tuesday (2). Year $Y=76$. $Offset = \lfloor 76/12 \rfloor + (76 \pmod{12}) + \lfloor (76 \pmod{12})/4 \rfloor$ $Offset = 6 + 4 + \lfloor 4/4 \rfloor = 6 + 4 + 1 = 11$. Doomsday for 1776 = $(2 + 11) \pmod{7} = 13 \pmod{7} = 6$ (Saturday). July 4th is 3 days before July 7th (a Doomsday). $Saturday - 3\ days = Wednesday$. So, $July\ 4, 1776$ was a Wednesday. ISO 8601 Date and Time Format Standard for representing dates and times. Date: $YYYY-MM-DD$ (e.g., $2023-10-27$) Time: $HH:MM:SS$ (e.g., $14:30:00$) Combined: $YYYY-MM-DDTHH:MM:SS$ (e.g., $2023-10-27T14:30:00$) Time Zones: $Z$ for UTC (Zulu time): $2023-10-27T14:30:00Z$ Offset from UTC: $2023-10-27T14:30:00+01:00$ (one hour ahead of UTC) Week Dates: $YYYY-Www-D$ (e.g., $2023-W43-5$ for Friday of week 43 in 2023) Epoch Time (Unix Time) Number of seconds that have elapsed since $00:00:00$ UTC on $January\ 1, 1970$. Widely used in computing systems. Example: $1700000000$ corresponds to $November\ 14, 2023, 02:46:40$ UTC.