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()); }
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()); }