bug51096.phpt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Bug #51096 (Test for "first day" vs "first day of")
  3. --FILE--
  4. <?php
  5. $tests = array(
  6. 'first day',
  7. 'last day',
  8. 'next month',
  9. 'first day next month',
  10. 'last day next month',
  11. 'first day of next month',
  12. 'last day of next month'
  13. );
  14. foreach ( $tests as $test )
  15. {
  16. $result = date_parse( $test );
  17. $rel = $result['relative'];
  18. echo $test, "\n- month: ", $rel['month'], '; day: ', $rel['day'],
  19. '; first-day-of: ', isset( $rel['first_day_of_month'] ) ? 'true' : 'false',
  20. '; last-day-of: ', isset( $rel['last_day_of_month'] ) ? 'true' : 'false', "\n";
  21. $date = new DateTime( '2010-03-06 15:21 UTC' );
  22. echo '- ', $date->format( DateTime::ISO8601 );
  23. $date->modify( $test );
  24. echo ' -> ', $date->format( DateTime::ISO8601 ), "\n\n";
  25. }
  26. ?>
  27. --EXPECT--
  28. first day
  29. - month: 0; day: 1; first-day-of: false; last-day-of: false
  30. - 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000
  31. last day
  32. - month: 0; day: -1; first-day-of: false; last-day-of: false
  33. - 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000
  34. next month
  35. - month: 1; day: 0; first-day-of: false; last-day-of: false
  36. - 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000
  37. first day next month
  38. - month: 1; day: 1; first-day-of: false; last-day-of: false
  39. - 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000
  40. last day next month
  41. - month: 1; day: -1; first-day-of: false; last-day-of: false
  42. - 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000
  43. first day of next month
  44. - month: 1; day: 0; first-day-of: true; last-day-of: false
  45. - 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000
  46. last day of next month
  47. - month: 1; day: 0; first-day-of: false; last-day-of: true
  48. - 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000