/* * [HumanRightsDay.java] * * Summary: calculate when Human Rights 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; import static java.lang.System.*; /** * calculate when Human Rights day occurs. * * @author Roedy Green, Canadian Mind Products * @version 4.2 2008-12-03 add World AIDS day * @since 1999 */ public final class HumanRightsDay extends HolInfo { /** * Test driver * * @param args not used */ public static void main( String[] args ) { HolInfo h = new HumanRightsDay(); out.println( h.getName() ); out.println( h.getFirstYear( OBSERVED ) ); out.println( h.getFirstYear( PROCLAIMED ) ); out.println( h.getRule() ); out.println( h.getAuthority() ); BigDate d = new BigDate( h.when( 1999, ACTUAL, OBSERVED ) ); out.println( d.getYYYY() + "/" + d.getMM() + "/" + d.getDD() ); d.setOrdinal( h.when( 1999, SHIFTED, OBSERVED ) ); out.println( d.getYYYY() + "/" + d.getMM() + "/" + d.getDD() ); } // end main /** * @inheritDoc */ public String getAuthority() { return "United Nations resolution 423.\n" + "http://www.un.org/events/humanrights/2004/index.htm.\n" + "Human Rights Day marks the anniversary of the Assembly\u2019s\n" + "adoption of the Universal Declaration of Human Rights in 1948."; } /** * @inheritDoc */ public int getFirstYear( int base ) { return 1950; } /** * @inheritDoc */ public String getName() { return "Human Rights Day"; } /** * @inheritDoc */ public String getRule() { return "Always on Dec 10."; } /** * Always on Dec 10. * * @param year (-ve means BC, +ve means AD, 0 not permitted.) * @param shift true if want date of holiday shifted to nearest weekday. * @param base PROCLAIMED=based on date holiday was officially proclaimed CELEBRATED=based on date holiday was * first celebrated * * @return ordinal days since 1970-01-01. return NULL_ORDINAL if the holiday was not celebrated in that year. */ public int when( int year, boolean shift, int base ) { if ( !isYearValid( year, base ) ) { return BigDate.NULL_ORDINAL; } return shiftSatToFriSunToMon( BigDate.toOrdinal( year, 12, 10 ), shift ); } // end when. }