Back to index

php5  5.3.10
DateTime_data-dates.inc
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * Note: test names match method names in a set of PHPUnit tests
00005  * in a userland package.  Please be so kind as to leave them.
00006  */
00007 
00008 date_default_timezone_set('America/New_York');
00009 
00010 
00011 /*
00012  * Particular days
00013  */
00014 echo "test__7: ";
00015 examine_diff('2009-01-14', '2009-01-07', 'P+0Y0M7DT0H0M0S', 7);
00016 
00017 echo "test_years_positive__7_by_0_day: ";
00018 examine_diff('2007-02-07', '2000-02-07', 'P+7Y0M0DT0H0M0S', 2557);
00019 
00020 echo "test_years_positive__7_by_1_day: ";
00021 examine_diff('2007-02-08', '2000-02-07', 'P+7Y0M1DT0H0M0S', 2558);
00022 
00023 // NOTE: sub() produces different answer.
00024 echo "test_years_positive__6_shy_1_day: ";
00025 examine_diff('2007-02-06', '2000-02-07', 'P+6Y11M30DT0H0M0S', 2556);
00026 
00027 echo "test_years_positive__7_by_1_month: ";
00028 examine_diff('2007-03-07', '2000-02-07', 'P+7Y1M0DT0H0M0S', 2585);
00029 
00030 echo "test_years_positive__6_shy_1_month: ";
00031 examine_diff('2007-01-07', '2000-02-07', 'P+6Y11M0DT0H0M0S', 2526);
00032 
00033 echo "test_years_positive__7_by_1_month_split_newyear: ";
00034 examine_diff('2007-01-07', '1999-12-07', 'P+7Y1M0DT0H0M0S', 2588);
00035 
00036 echo "test_years_positive__6_shy_1_month_split_newyear: ";
00037 examine_diff('2006-12-07', '2000-01-07', 'P+6Y11M0DT0H0M0S', 2526);
00038 
00039 
00040 /*
00041  * Particular days, negative
00042  */
00043 echo "test_negative__7: ";
00044 examine_diff('2009-01-07', '2009-01-14', 'P-0Y0M7DT0H0M0S', 7);
00045 
00046 echo "test_years_negative__7_by_0_day: ";
00047 examine_diff('2000-02-07', '2007-02-07', 'P-7Y0M0DT0H0M0S', 2557);
00048 
00049 echo "test_years_negative__7_by_1_day: ";
00050 examine_diff('2000-02-07', '2007-02-08', 'P-7Y0M1DT0H0M0S', 2558);
00051 
00052 // NOTE: sub() produces different answer.
00053 echo "test_years_negative__6_shy_1_day: ";
00054 examine_diff('2000-02-07', '2007-02-06', 'P-6Y11M28DT0H0M0S', 2556);
00055 
00056 echo "test_years_negative__7_by_1_month: ";
00057 examine_diff('2000-02-07', '2007-03-07', 'P-7Y1M0DT0H0M0S', 2585);
00058 
00059 echo "test_years_negative__6_shy_1_month: ";
00060 examine_diff('2000-02-07', '2007-01-07', 'P-6Y11M0DT0H0M0S', 2526);
00061 
00062 echo "test_years_negative__7_by_1_month_split_newyear: ";
00063 examine_diff('1999-12-07', '2007-01-07', 'P-7Y1M0DT0H0M0S', 2588);
00064 
00065 echo "test_years_negative__6_shy_1_month_split_newyear: ";
00066 examine_diff('2000-01-07', '2006-12-07', 'P-6Y11M0DT0H0M0S', 2526);