HKI Core
DayMonthYear.cs
Go to the documentation of this file.
1 using UnityEngine;
2 
3 namespace HKI.Core.Variables
4 {
5  [System.Serializable]
6  public struct DayMonthYear
7  {
8  // Enum
9  [System.Serializable]
10  public enum Months
11  {
12  January,
13  February,
14  March,
15  April,
16  May,
17  June,
18  July,
19  August,
20  September,
21  October,
22  November,
23  December
24  }
25 
26  [System.Serializable]
28  {
29  BC,
30  AD
31  }
32 
33  // Public variables
34  public int Day;
35  public Months Month;
36  public int Year;
38 
39  // Constructor
40  public DayMonthYear(int day, Months month, int year, BeforeChristAnnoDomini bcad)
41  {
42  Day = day;
43  Month = month;
44  Year = year;
45  BCAD = bcad;
46  }
47 
49  {
50  Day = date.Day;
51  Month = date.Month;
52  Year = date.Year;
53  BCAD = date.BCAD;
54  }
55 
56  // Interface fucntion
57  public override string ToString()
58  {
59  return Day.ToString() + "." + Month.ToString() + "." + Year.ToString();
60  }
61 
62  public bool ValidateDay()
63  {
64  if(Day < 0)
65  return false;
66 
67  switch(Month)
68  {
69  case Months.January:
70  case Months.March:
71  case Months.May:
72  case Months.July:
73  case Months.August:
74  case Months.October:
75  case Months.December:
76  if (Day > 31)
77  return false;
78  break;
79 
80  case Months.April:
81  case Months.June:
82  case Months.September:
83  case Months.November:
84  if (Day > 30)
85  return false;
86  break;
87 
88  case Months.February:
89  if(Day > 29)
90  return false;
91  else if(Day > 28 && ((Year % 4 != 0) || ((Year % 100 == 0) && (Year % 400 != 0))))
92  return false;
93  break;
94  }
95 
96  return true;
97  }
98  }
99 }
DayMonthYear(int day, Months month, int year, BeforeChristAnnoDomini bcad)
Definition: DayMonthYear.cs:40
BeforeChristAnnoDomini BCAD
Definition: DayMonthYear.cs:37
DayMonthYear(DayMonthYear date)
Definition: DayMonthYear.cs:48