|
@@ -19,8 +19,103 @@ namespace AvaloniaApplication1
|
|
|
{
|
|
|
string date = dateT.SelectedDate.ToString();
|
|
|
|
|
|
- int day = int.Parse(date.Substring(0, 2));
|
|
|
- int mounth = int.Parse(date.Substring(3, 2));
|
|
|
+ if (date == "")
|
|
|
+ {
|
|
|
+ mounthT.Text = "Âû ââåëè íåñóùåñòâóþùóþ äàòó";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int day = int.Parse(date.Substring(0, 2));
|
|
|
+ int mounth = int.Parse(date.Substring(3, 2));
|
|
|
+ int year = int.Parse(date.Substring(6, 4));
|
|
|
+
|
|
|
+ DateTime BD = new DateTime(year, mounth, day);
|
|
|
+ DateTime ToDay = DateTime.Now;
|
|
|
+
|
|
|
+
|
|
|
+ if (BD > ToDay)
|
|
|
+ {
|
|
|
+ mounthT.Text = "Âû ââåëè áóäóùóþ äàòó";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int Vis = 0;
|
|
|
+ int DbWeek = 0;
|
|
|
+ DateTime dayW;
|
|
|
+ int age = ToDay.Year - BD.Year;
|
|
|
+ int months = ToDay.Month - BD.Month;
|
|
|
+ int days = ToDay.Day - BD.Day;
|
|
|
+
|
|
|
+ if (ToDay.Month < BD.Month || (ToDay.Month == BD.Month && ToDay.Day < BD.Day))
|
|
|
+ {
|
|
|
+ age--;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (days < 0)
|
|
|
+ {
|
|
|
+ months--;
|
|
|
+ days += DateTime.DaysInMonth(ToDay.Year, ToDay.Month - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (months < 0)
|
|
|
+ {
|
|
|
+ months += 12;
|
|
|
+ }
|
|
|
+ VisY.Text = "Âèñîêîñíûå ãîäû: ";
|
|
|
+ string DayOfWeek = BD.DayOfWeek.ToString();
|
|
|
+ for (int i = year; i <= ToDay.Year; i++)
|
|
|
+ {
|
|
|
+ if (i % 4 == 0)
|
|
|
+ {
|
|
|
+
|
|
|
+ VisY.Text = VisY.Text + i + " ";
|
|
|
+ Vis++;
|
|
|
+ }
|
|
|
+ dayW = new DateTime(i, mounth, day);
|
|
|
+
|
|
|
+ if (dayW.DayOfWeek.ToString() == DayOfWeek && dayW != BD && dayW != ToDay)
|
|
|
+ {
|
|
|
+ DbWeek++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DayOfWeek == "Monday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Ïîíåäåëüíèê";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Tuesday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Âòîðíèê";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Wednesday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Ñðåäà";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Thursday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "×åòâåðã";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Friday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Ïÿòíèöà";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Saturday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Ñóááîòà";
|
|
|
+ }
|
|
|
+ if (DayOfWeek == "Sunday")
|
|
|
+ {
|
|
|
+ DayOfWeek = "Âîñêðåñåíüå";
|
|
|
+ }
|
|
|
+
|
|
|
+ dayOfWeek.Text = "Äåíü íåäåëè: " + DayOfWeek;
|
|
|
+ yearT.Text = "Êîëè÷åñòâî ëåò: " + age.ToString();
|
|
|
+ mounthT.Text = "Êîëè÷åñòâî ìåñÿöåâ: " + months.ToString();
|
|
|
+ daysT.Text = "Êîëè÷åñòâî äíåé: " + days.ToString();
|
|
|
+ DBW.Text = "Êîëè÷åñòâî îòïðàçäíîâàííûõ äíåé ðîæäåíèé â " + DayOfWeek + ": " + DbWeek;
|
|
|
+ Viss.Text = "Êîëè÷åñòâî âèñîêîñíûõ ãîäîâ: " + Vis;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|