示例#1
0
文件: Singapore.cs 项目: kwangphys/QT
            public override bool isBusinessDay(DateTime date)
            {
                DayOfWeek w = date.DayOfWeek;
                int       d = date.Day, dd = date.DayOfYear;
                Month     m  = (Month)date.Month;
                int       y  = date.Year;
                int       em = easterMonday(y);

                if (isWeekend(w)
                    // New Year's Day
                    || ((d == 1 || (d == 2 && w == DayOfWeek.Monday)) && m == Month.January)
                    // Good Friday
                    || (dd == em - 3)
                    // Labor Day
                    || ((d == 1 || (d == 2 && w == DayOfWeek.Monday)) && m == Month.May)
                    // National Day
                    || ((d == 9 || (d == 10 && w == DayOfWeek.Monday)) && m == Month.August)
                    // Christmas Day
                    || ((d == 25 || (d == 26 && w == DayOfWeek.Monday)) && m == Month.December)

                    // Chinese New Year
                    || ((d == 22 || d == 23) && m == Month.January && y == 2004) ||
                    ((d == 9 || d == 10) && m == Month.February && y == 2005) ||
                    ((d == 30 || d == 31) && m == Month.January && y == 2006) ||
                    ((d == 19 || d == 20) && m == Month.February && y == 2007) ||
                    ((d == 7 || d == 8) && m == Month.February && y == 2008) ||
                    ((d == 26 || d == 27) && m == Month.January && y == 2009) ||
                    ((d == 15 || d == 16) && m == Month.January && y == 2010) ||
                    ((d == 23 || d == 24) && m == Month.January && y == 2012) ||
                    ((d == 11 || d == 12) && m == Month.February && y == 2013) ||
                    (d == 31 && m == Month.January && y == 2014) ||
                    (d == 1 && m == Month.February && y == 2014) ||
                    ((d == 19 || d == 20) && m == Month.February && y == 2015) ||
                    ((d == 8 || d == 9) && m == Month.February && y == 2016) ||
                    ((d == 28 || d == 29 || d == 30) && m == Month.January && y == 2017)

                    // Vesak Day
                    || (d == 2 && m == Month.June && y == 2004) ||
                    (d == 22 && m == Month.May && y == 2005) ||
                    (d == 12 && m == Month.May && y == 2006) ||
                    (d == 31 && m == Month.May && y == 2007) ||
                    (d == 18 && m == Month.May && y == 2008) ||
                    (d == 9 && m == Month.May && y == 2009) ||
                    (d == 28 && m == Month.May && y == 2010) ||
                    (d == 5 && m == Month.May && y == 2012) ||
                    (d == 24 && m == Month.May && y == 2013) ||
                    (d == 13 && m == Month.May && y == 2014) ||
                    (d == 1 && m == Month.June && y == 2015) ||
                    (d == 21 && m == Month.May && y == 2016) ||
                    (d == 10 && m == Month.May && y == 2017)

                    // Hari Raya Puasa
                    || ((d == 14 || d == 15) && m == Month.November && y == 2004) ||
                    (d == 3 && m == Month.November && y == 2005) ||
                    (d == 24 && m == Month.October && y == 2006) ||
                    (d == 13 && m == Month.October && y == 2007) ||
                    (d == 1 && m == Month.October && y == 2008) ||
                    (d == 21 && m == Month.September && y == 2009) ||
                    (d == 10 && m == Month.September && y == 2010) ||
                    (d == 20 && m == Month.August && y == 2012) ||
                    (d == 8 && m == Month.August && y == 2013) ||
                    (d == 28 && m == Month.July && y == 2014) ||
                    (d == 17 && m == Month.July && y == 2015) ||
                    (d == 6 && m == Month.July && y == 2016) ||
                    ((d == 25 || d == 26) && m == Month.June && y == 2017)

                    // Hari Raya Haji
                    || ((d == 1 || d == 2) && m == Month.February && y == 2004) ||
                    (d == 21 && m == Month.January && y == 2005) ||
                    (d == 10 && m == Month.January && y == 2006) ||
                    (d == 2 && m == Month.January && y == 2007) ||
                    (d == 20 && m == Month.December && y == 2007) ||
                    (d == 8 && m == Month.December && y == 2008) ||
                    (d == 27 && m == Month.November && y == 2009) ||
                    (d == 17 && m == Month.November && y == 2010) ||
                    (d == 26 && m == Month.October && y == 2012) ||
                    (d == 15 && m == Month.October && y == 2013) ||
                    (d == 6 && m == Month.October && y == 2014) ||
                    (d == 24 && m == Month.September && y == 2015) ||
                    (d == 12 && m == Month.September && y == 2016) ||
                    (d == 1 && m == Month.September && y == 2017)

                    // Deepavali
                    || (d == 11 && m == Month.November && y == 2004) ||
                    (d == 1 && m == Month.November && y == 2005) ||
                    (d == 8 && m == Month.November && y == 2007) ||
                    (d == 28 && m == Month.October && y == 2008) ||
                    (d == 16 && m == Month.November && y == 2009) ||
                    (d == 5 && m == Month.November && y == 2010) ||
                    (d == 13 && m == Month.November && y == 2012) ||
                    (d == 4 && m == Month.November && y == 2013) ||
                    (d == 23 && m == Month.October && y == 2014) ||
                    (d == 10 && m == Month.November && y == 2015) ||
                    (d == 29 && m == Month.October && y == 2016) ||
                    (d == 18 && m == Month.October && y == 2017)

                    // other events
                    // SG50
                    || (d == 7 && m == Month.August && y == 2015)
                    // Polling Day
                    || (d == 11 && m == Month.September && y == 2015)
                    )
                {
                    return(false);
                }
                return(true);
            }
示例#2
0
文件: Japan.cs 项目: kwangphys/QT
            public override bool isBusinessDay(DateTime date)
            {
                DayOfWeek w = date.DayOfWeek;
                int       d = date.Day, dd = date.DayOfYear;
                Month     m = (Month)date.Month;
                int       y = date.Year;

                // equinox calculation
                double exact_vernal_equinox_time   = 20.69115;
                double exact_autumnal_equinox_time = 23.09;
                double diff_per_year        = 0.242194;
                double moving_amount        = (y - 2000) * diff_per_year;
                int    number_of_leap_years = (y - 2000) / 4 + (y - 2000) / 100 - (y - 2000) / 400;
                int    ve = (int)(exact_vernal_equinox_time + moving_amount - number_of_leap_years);   // vernal equinox day
                int    ae = (int)(exact_autumnal_equinox_time + moving_amount - number_of_leap_years); // autumnal equinox day

                // checks
                if (isWeekend(w)
                    // New Year's Day
                    || (d == 1 && m == Month.January)
                    // Bank Holiday
                    || (d == 2 && m == Month.January)
                    // Bank Holiday
                    || (d == 3 && m == Month.January)
                    // Coming of Age Day (2nd Monday in January),
                    // was January 15th until 2000
                    || (w == DayOfWeek.Monday && (d >= 8 && d <= 14) && m == Month.January &&
                        y >= 2000) ||
                    ((d == 15 || (d == 16 && w == DayOfWeek.Monday)) && m == Month.January &&
                     y < 2000)
                    // National Foundation Day
                    || ((d == 11 || (d == 12 && w == DayOfWeek.Monday)) && m == Month.February)
                    // Vernal Equinox
                    || ((d == ve || (d == ve + 1 && w == DayOfWeek.Monday)) && m == Month.March)
                    // Greenery Day
                    || ((d == 29 || (d == 30 && w == DayOfWeek.Monday)) && m == Month.April)
                    // Constitution Memorial Day
                    || (d == 3 && m == Month.May)
                    // Holiday for a Nation
                    || (d == 4 && m == Month.May)
                    // Children's Day
                    || (d == 5 && m == Month.May)
                    // any of the three above observed later if on Saturday or Sunday
                    || (d == 6 && m == Month.May && (w == DayOfWeek.Monday || w == DayOfWeek.Tuesday || w == DayOfWeek.Wednesday))
                    // Marine Day (3rd Monday in July),
                    // was July 20th until 2003, not a holiday before 1996
                    || (w == DayOfWeek.Monday && (d >= 15 && d <= 21) && m == Month.July &&
                        y >= 2003) ||
                    ((d == 20 || (d == 21 && w == DayOfWeek.Monday)) && m == Month.July &&
                     y >= 1996 && y < 2003)
                    // Mountain Day (from 2016)
                    || (d == 11 && m == Month.August && y >= 2016)
                    // Respect for the Aged Day (3rd Monday in September),
                    // was September 15th until 2003
                    || (w == DayOfWeek.Monday && (d >= 15 && d <= 21) && m == Month.September &&
                        y >= 2003) ||
                    ((d == 15 || (d == 16 && w == DayOfWeek.Monday)) && m == Month.September &&
                     y < 2003)
                    // If a single day falls between Respect for the Aged Day
                    // and the Autumnal Equinox, it is holiday
                    || (w == DayOfWeek.Tuesday && d + 1 == ae && d >= 16 && d <= 22 &&
                        m == Month.September && y >= 2003)
                    // Autumnal Equinox
                    || ((d == ae || (d == ae + 1 && w == DayOfWeek.Monday)) && m == Month.September)
                    // Health and Sports Day (2nd Monday in October),
                    // was October 10th until 2000
                    || (w == DayOfWeek.Monday && (d >= 8 && d <= 14) && m == Month.October &&
                        y >= 2000) ||
                    ((d == 10 || (d == 11 && w == DayOfWeek.Monday)) && m == Month.October &&
                     y < 2000)
                    // National Culture Day
                    || ((d == 3 || (d == 4 && w == DayOfWeek.Monday)) && m == Month.November)
                    // Labor Thanksgiving Day
                    || ((d == 23 || (d == 24 && w == DayOfWeek.Monday)) && m == Month.November)
                    // Emperor's Birthday
                    || ((d == 23 || (d == 24 && w == DayOfWeek.Monday)) && m == Month.December &&
                        y >= 1989)
                    // Bank Holiday
                    || (d == 31 && m == Month.December)
                    // one-shot holidays
                    // Marriage of Prince Akihito
                    || (d == 10 && m == Month.April && y == 1959)
                    // Rites of Imperial Funeral
                    || (d == 24 && m == Month.February && y == 1989)
                    // Enthronement Ceremony
                    || (d == 12 && m == Month.November && y == 1990)
                    // Marriage of Prince Naruhito
                    || (d == 9 && m == Month.June && y == 1993))
                {
                    return(false);
                }
                return(true);
            }