/* * [InaugurationDay.java] * * Summary: calculate when US presidential Inauguration day occurs. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 4.2 2008-12-03 add World AIDS day */ package com.mindprod.holidays; import com.mindprod.common18.BigDate; /** * calculate when US presidential Inauguration day occurs. * * @author Roedy Green, Canadian Mind Products * @version 4.2 2008-12-03 add World AIDS day * @since 1999 */ public final class InaugurationDay extends HolInfo { /** * @inheritDoc */ public String getAuthority() { // http://edsitement.neh.fed.us/lessonplans/inaugurations.html // http://edsitement.neh.fed.us/lessonplans/inaugurations.html return "http://www.geocities.com/holidaymobley/InaugurationDay.html"; } /** * @inheritDoc */ public int getFirstYear( int base ) { return 1789; } /** * @inheritDoc */ public String getName() { return "US Presidential Inauguration Day"; } /** * @inheritDoc */ public String getRule() { return "noon, January 20, every four years, but never on a Sunday."; // Ford : 1974-08-09, (unscheduled) // Carter: 1977-10-20 Tuesday // Reagan: 1981-01-20 Tuesday // Bush Sr. 1989-01-20Friday // Clinton: 19930-01-20 Wednesday // Bush Jr: 2001-01-20 Saturday // Bush second: 2005-01-20 Thursday } /** * @inheritDoc */ public int when( int year, boolean shift, int base ) { if ( !isYearValid( year, base ) ) { return BigDate.NULL_ORDINAL; } if ( year % 4 != 1 ) { return BigDate.NULL_ORDINAL; } int ordinal; if ( year == 1789 ) { ordinal = BigDate.toOrdinal( year, 4, 30 ); } else if ( year < 1937 ) { /* March 4 */ ordinal = BigDate.toOrdinal( year, 3, 4 ); } else { /* January 20 */ ordinal = BigDate.toOrdinal( year, 1, 20 ); } if ( BigDate.dayOfWeek( ordinal ) == 0 ) { /* sunday shift to Monday */ ordinal++; } return shiftSatToFriSunToMon( ordinal, shift ); } // end when. }