Exemple #1
0
        static int KcNgay(MyDate c)
        {
            int m      = c.Doc_m();
            int nNhuan = c.Doc_y() / 4;
            int kq     = 0;

            do
            {
                if (m == 1 || m == 3 || m == 5 ||
                    m == 7 || m == 8 ||
                    m == 10 || m == 12)
                {
                    kq += m * 31;
                }
                else if (m == 4 || m == 6 || m == 9 || m == 11)
                {
                    kq += m * 30;
                }
                else if (m == 2 && c.KtYear(c.Doc_y()))
                {
                    kq += 29;
                }
                else
                {
                    kq += 28;
                }
                --m;
            } while (m != 0);
            kq += (nNhuan * 366 + (c.Doc_y() - nNhuan) * 365);
            return(kq += c.Doc_d());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            MyDate d  = new MyDate(30, 2, 2009);
            MyDate d2 = new MyDate(5, 11, 2003);

            Console.WriteLine(d.before(d2));
            Console.WriteLine(d.date());

            Students s1 = new Students("Barak", "Weisler", d);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            MyDate a, b, c;

            c = new MyDate();
            nhapDate(out a);
            nhapDate(out b);
            c.khoiTao(a);
            kCach(a, b, ref c);
            a.xuatD();
            b.xuatD();
            c.xuatD();
            int kq = KcNgay(c);

            Console.WriteLine("\nngay :{0}", kq);
        }
Exemple #4
0
        public bool before(MyDate d)
        {
            bool before = false;

            if (d.get_day() > 1)
            {
                if ((d.get_day() == this.day + 1) && (d.get_month() == this.month) && (d.get_year() == this.year))
                {
                    before = true;
                }
            }
            else if (d.get_day() == 1)
            {
                if ((this.day == 31) && (d.get_month() - 1 == this.month) && (d.get_year() == this.year))
                {
                    before = true;
                }
                else if ((this.day == 31) && (this.month == 12) && (this.year + 1 == d.get_year()))
                {
                    before = true;
                }
            }
            return(before);
        }
Exemple #5
0
 public void set_d(MyDate d)
 {
     this.BirthDate = d;
 }
Exemple #6
0
 public Students()//בנאי
 {
     this.FirstName = null;
     this.LastName  = null;
     this.BirthDate = new MyDate();
 }
Exemple #7
0
 public Students(string f, string L, MyDate B)//בנאי
 {
     this.FirstName = f;
     this.LastName  = L;
     this.BirthDate = B;
 }
Exemple #8
0
 static void Main(string[] args)
 {
     DateTime a = new DateTime(2017, 1, 18);
     MyDate   d = new MyDate(a);
     // d.Date();
 }
Exemple #9
0
 public void khoiTao(MyDate a)
 {
     m_d = a.m_d;
     m_m = a.m_m;
     m_y = a.m_y;
 }
Exemple #10
0
 static void kCach(MyDate a, MyDate b, ref MyDate c)
 {
     c.Gan_d(a.Doc_d() - b.Doc_d());
     c.Gan_m(a.Doc_m() - b.Doc_m());
     c.Gan_y(a.Doc_y() - b.Doc_y());
 }
Exemple #11
0
 static void nhapDate(out MyDate a)
 {
     a = new MyDate();
     a.nhapD();
 }