1<?php
2
3/*
4 * Note: test names match method names in a set of PHPUnit tests
5 * in a userland package.  Please be so kind as to leave them.
6 */
7
8date_default_timezone_set('America/New_York');
9
10
11/*
12 * Particular days
13 */
14echo "test__7: ";
15examine_diff('2009-01-14', '2009-01-07', 'P+0Y0M7DT0H0M0S', 7);
16
17echo "test_years_positive__7_by_0_day: ";
18examine_diff('2007-02-07', '2000-02-07', 'P+7Y0M0DT0H0M0S', 2557);
19
20echo "test_years_positive__7_by_1_day: ";
21examine_diff('2007-02-08', '2000-02-07', 'P+7Y0M1DT0H0M0S', 2558);
22
23// NOTE: sub() produces different answer.
24echo "test_years_positive__6_shy_1_day: ";
25examine_diff('2007-02-06', '2000-02-07', 'P+6Y11M30DT0H0M0S', 2556);
26
27echo "test_years_positive__7_by_1_month: ";
28examine_diff('2007-03-07', '2000-02-07', 'P+7Y1M0DT0H0M0S', 2585);
29
30echo "test_years_positive__6_shy_1_month: ";
31examine_diff('2007-01-07', '2000-02-07', 'P+6Y11M0DT0H0M0S', 2526);
32
33echo "test_years_positive__7_by_1_month_split_newyear: ";
34examine_diff('2007-01-07', '1999-12-07', 'P+7Y1M0DT0H0M0S', 2588);
35
36echo "test_years_positive__6_shy_1_month_split_newyear: ";
37examine_diff('2006-12-07', '2000-01-07', 'P+6Y11M0DT0H0M0S', 2526);
38
39
40/*
41 * Particular days, negative
42 */
43echo "test_negative__7: ";
44examine_diff('2009-01-07', '2009-01-14', 'P-0Y0M7DT0H0M0S', 7);
45
46echo "test_years_negative__7_by_0_day: ";
47examine_diff('2000-02-07', '2007-02-07', 'P-7Y0M0DT0H0M0S', 2557);
48
49echo "test_years_negative__7_by_1_day: ";
50examine_diff('2000-02-07', '2007-02-08', 'P-7Y0M1DT0H0M0S', 2558);
51
52// NOTE: sub() produces different answer.
53echo "test_years_negative__6_shy_1_day: ";
54examine_diff('2000-02-07', '2007-02-06', 'P-6Y11M28DT0H0M0S', 2556);
55
56echo "test_years_negative__7_by_1_month: ";
57examine_diff('2000-02-07', '2007-03-07', 'P-7Y1M0DT0H0M0S', 2585);
58
59echo "test_years_negative__6_shy_1_month: ";
60examine_diff('2000-02-07', '2007-01-07', 'P-6Y11M0DT0H0M0S', 2526);
61
62echo "test_years_negative__7_by_1_month_split_newyear: ";
63examine_diff('1999-12-07', '2007-01-07', 'P-7Y1M0DT0H0M0S', 2588);
64
65echo "test_years_negative__6_shy_1_month_split_newyear: ";
66examine_diff('2000-01-07', '2006-12-07', 'P-6Y11M0DT0H0M0S', 2526);
67