Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MyProgram
- {
- class ClassDate
- {
- DateTime date;
- // static DateTime date1;
- //static ClassDate() //статический конструктор
- //{
- // date1 = DateTime.Parse(Console.ReadLine());
- // //Console.WriteLine("Заданная дата - {0}", date1);
- //}
- public ClassDate()
- {
- date = new DateTime(2010, 1, 1);
- //Console.WriteLine("Определенная дата - {0}", date);
- }
- public ClassDate(DateTime date)
- {
- this.date = date;
- // Console.WriteLine("Заданная дата №2 - {0}", date);
- }
- public DateTime PreviousDay()
- {
- return date.Subtract(TimeSpan.FromDays(1));
- }
- public DateTime NextDay()
- {
- return date.Add(TimeSpan.FromDays(1));
- }
- public int DaysLeft()
- {
- return DateTime.DaysInMonth(date.Year, date.Month) - date.Day;
- }
- public DateTime Date
- {
- get { return date; }
- set { date = value; }
- }
- public bool IsLeap
- {
- get { return DateTime.IsLeapYear(date.Year); }
- }
- public DateTime this[int days]
- {
- get { return date.AddDays(days); }
- }
- public static bool operator !(ClassDate a)
- {
- return DateTime.DaysInMonth(a.Date.Year, a.Date.Month) != a.Date.Day;
- }
- public static bool operator true(ClassDate a)
- {
- return a.date.Month == 1;
- }
- public static bool operator false(ClassDate a)
- {
- return a.date.Month != 1;
- }
- public static bool operator &(ClassDate a, ClassDate b)
- {
- return a.Date.Equals(b.Date);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement