Village.Database.DateTimeExtension
Contains the informations to get the Season or PeriodOfDay from a DateTime.
It use a table for the season and the period, so that season dont start on exact date, but are averaged by month.
The same way, period of day are averaged by hours, without regards for seasons
| GetSeason(DateTime) : Season | Return the Season based on the DateTime month |
|---|---|
| GetPeriodOfDay(DateTime) : PeriodOfDay | Return the Season based oin the DateTime hour |
<aside> 📌
Period of day does not account for the current season, and is assumed to be local.
</aside>
private static Season[] _seasonTable = new Season[]
{
Season.Winter, //January
Season.Winter, //Febuary
Season.Spring, //March
Season.Spring, //April
Season.Spring, //May
Season.Summer, //June
Season.Summer, //July
Season.Summer, //August
Season.Fall, //September
Season.Fall, //October
Season.Fall, //November
Season.Winter, //December
};
private static PeriodOfDay[] _periodOfDayTable = new PeriodOfDay[]
{
PeriodOfDay.Night, //0
PeriodOfDay.Night, //1
PeriodOfDay.Night, //2
PeriodOfDay.Night, //3
PeriodOfDay.Night, //4
PeriodOfDay.Night, //5
PeriodOfDay.Sunrise, //6
PeriodOfDay.Sunrise, //7
PeriodOfDay.Sunrise, //8
PeriodOfDay.Morning, //9
PeriodOfDay.Morning, //10
PeriodOfDay.Morning, //11
PeriodOfDay.Morning, //12
PeriodOfDay.Morning, //13
PeriodOfDay.Afternoon, //14
PeriodOfDay.Afternoon, //15
PeriodOfDay.Afternoon, //16
PeriodOfDay.Sunset, //17
PeriodOfDay.Sunset, //18
PeriodOfDay.Sunset, //19
PeriodOfDay.Night, //20
PeriodOfDay.Night, //21
PeriodOfDay.Night, //22
PeriodOfDay.Night, //23
};