// THIS FILE IS PART OF ChineseCalendar PROJECT
// THE ChineseCalendar PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MIT License.
// COPYRIGHT (C) lpz. ALL RIGHTS RESERVED.
// GITEE: https://gitee.com/lipz89/ChineseCalendar
using System;
using System.Collections.Generic;
namespace ChineseCalendar
{
///
/// 节日
///
public abstract class Festival
{
/// 节日名称
public string Name { get; protected set; }
/// 描述
public string Description { get; protected set; }
/// 节日设立年份
public int? FirstYear { get; protected set; }
/// 月份
public int Month { get; protected set; }
/// 日期
public int Day { get; protected set; }
///
/// 获取指定公历日期前一个节日
///
/// 指定公历日期
/// 是否包含指定日期
/// 前一个节日,null表示前面没有该节日
public abstract DateTime? GetLastDate(DateTime? date = null, bool containsThisDate = false);
///
/// 获取指定公历日期后一个节日
///
/// 指定公历日期
/// 是否包含指定日期
/// 后一个节日,null表示后面没有该节日
public abstract DateTime? GetNextDate(DateTime? date = null, bool containsThisDate = false);
///
/// 判断指定公历日期是否本节日
///
/// 指定公历日期
/// true该日期是当前节日,否则不是
public abstract bool IsThisFestival(DateTime date);
///
public override string ToString()
{
return this.Name;
}
///
/// 返回所有预定义的节日
///
///
public static IEnumerable GetAllDefined()
{
yield return GregorianFestival.NewYearsDay;
yield return GregorianFestival.TheTombWeepingDay;
yield return GregorianFestival.InternationalWorkersDay;
yield return GregorianFestival.TheNationalDay;
yield return ChineseFestival.SpringFestival;
yield return ChineseFestival.LanternFestival;
yield return ChineseFestival.DragonBoatFestival;
yield return ChineseFestival.QixiFestival;
yield return ChineseFestival.MidAutumnFestival;
yield return ChineseFestival.DoubleNinthFestival;
yield return ChineseFestival.NewYearsEve;
}
}
}