123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using Avalonia.Controls;
- using Avalonia.Interactivity;
- using System;
- using System.Data;
- using System.Diagnostics;
- using System.Runtime.Intrinsics.Arm;
- namespace AvaloniaApplication1
- {
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
-
-
- }
- public void Button_Click(object source, RoutedEventArgs args)
- {
- string date = dateT.SelectedDate.ToString();
- 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;
- }
- }
- }
- }
- }
|