File: bug51096.phpt

package info (click to toggle)
php5 5.3.3.1-7%2Bsqueeze29
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 123,520 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (55 lines) | stat: -rw-r--r-- 1,687 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--TEST--
Bug #51096: Test for "first day" vs "first day of".
--FILE--
<?php
$tests = array(
	'first day',
	'last day',
	'next month',
	'first day next month',
	'last day next month',
	'first day of next month',
	'last day of next month'
);

foreach ( $tests as $test )
{
	$result = date_parse( $test );
	$rel = $result['relative'];
	echo $test, "\n- month: ", $rel['month'], '; day: ', $rel['day'],
		 '; first-day-of: ', isset( $rel['first_day_of_month'] ) ? 'true' : 'false', 
		 '; last-day-of: ', isset( $rel['last_day_of_month'] ) ? 'true' : 'false', "\n";
	$date = new DateTime( '2010-03-06 15:21 UTC' );
	echo '- ', $date->format( DateTime::ISO8601 );
	$date->modify( $test );
	echo ' -> ', $date->format( DateTime::ISO8601 ), "\n\n";
}
?>
--EXPECT--
first day
- month: 0; day: 1; first-day-of: false; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-03-07T15:21:00+0000

last day
- month: 0; day: -1; first-day-of: false; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-03-05T15:21:00+0000

next month
- month: 1; day: 0; first-day-of: false; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-04-06T15:21:00+0000

first day next month
- month: 1; day: 1; first-day-of: false; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-04-07T15:21:00+0000

last day next month
- month: 1; day: -1; first-day-of: false; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-04-05T15:21:00+0000

first day of next month
- month: 1; day: 0; first-day-of: true; last-day-of: false
- 2010-03-06T15:21:00+0000 -> 2010-04-01T15:21:00+0000

last day of next month
- month: 1; day: 0; first-day-of: false; last-day-of: true
- 2010-03-06T15:21:00+0000 -> 2010-04-30T15:21:00+0000