Exemple #1
0
        public void DateDiff()
        {
            DateDiffImprecise dateDiff = new DateDiffImprecise();
            DateTime dateA = DateTime.Parse("2003-08-12");
            DateTime dateB = DateTime.Parse("2014-12-31");
            int n = dateDiff.YearDiff(dateA, dateB);
            Assert.AreEqual(n, 11);
            n = dateDiff.YearDiff(dateB, dateA);
            Assert.AreEqual(n, -11);

            dateA = DateTime.Parse("1953-01-03");
            dateB = DateTime.Parse("2015-01-02");
            n = dateDiff.YearDiff(dateA, dateB);
            Assert.AreEqual(n, 62);

            dateA = DateTime.Parse("2015-01-01");
            dateB = DateTime.Parse("2015-01-01");
            n = dateDiff.YearDiff(dateA, dateB);
            Assert.AreEqual(n, 0);

        }
Exemple #2
0
 public int AgeDifference(DateTime DateA, DateTime DateB)
 {
     DateDiffImprecise DateDiff = new DateDiffImprecise();
     return DateDiff.YearDiff(DateA, DateB);
 }