Skip to content

Commit 2790c0f

Browse files
committed
Fix GH-1181: Incorrect example for IntlDateFormatter::setPattern()
In addition to fixing the format specifiers, we also echo line breaks, so the output matches the example code.
1 parent d09a881 commit 2790c0f

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

reference/intl/dateformatter/set-pattern.xml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ $fmt = datefmt_create(
7777
IntlDateFormatter::GREGORIAN,
7878
'MM/dd/yyyy'
7979
);
80-
echo 'pattern of the formatter is : ' . datefmt_get_pattern($fmt);
81-
echo 'First Formatted output with pattern is ' . datefmt_format($fmt, 0);
82-
datefmt_set_pattern($fmt, 'yyyymmdd hh:mm:ss z');
83-
echo 'Now pattern of the formatter is : ' . datefmt_get_pattern($fmt);
84-
echo 'Second Formatted output with pattern is ' . datefmt_format($fmt, 0);
85-
80+
echo 'Pattern of the formatter is : ', datefmt_get_pattern($fmt), PHP_EOL;
81+
echo 'First Formatted output with pattern is ', datefmt_format($fmt, 0), PHP_EOL;
82+
datefmt_set_pattern($fmt, 'yyyyMMdd hh:mm:ss z');
83+
echo 'Now pattern of the formatter is : ', datefmt_get_pattern($fmt), PHP_EOL;
84+
echo 'Second Formatted output with pattern is ', datefmt_format($fmt, 0), PHP_EOL;
8685
?>
8786
]]>
8887
</programlisting>
@@ -99,25 +98,24 @@ $fmt = new IntlDateFormatter(
9998
IntlDateFormatter::GREGORIAN,
10099
'MM/dd/yyyy'
101100
);
102-
echo 'pattern of the formatter is : ' . $fmt->getPattern();
103-
echo 'First Formatted output is ' . $fmt->format(0);
104-
$fmt->setPattern('yyyymmdd hh:mm:ss z');
105-
echo 'Now pattern of the formatter is : ' . $fmt->getPattern();
106-
echo 'Second Formatted output is ' . $fmt->format(0);
107-
101+
echo 'Pattern of the formatter is : ', $fmt->getPattern(), PHP_EOL;
102+
echo 'First Formatted output is ', $fmt->format(0), PHP_EOL;
103+
$fmt->setPattern('yyyyMMdd hh:mm:ss z');
104+
echo 'Now pattern of the formatter is : ', $fmt->getPattern(), PHP_EOL;
105+
echo 'Second Formatted output is ', $fmt->format(0), PHP_EOL;
108106
?>
109107
]]>
110108
</programlisting>
111109
</example>
112-
&example.outputs;
113-
<screen>
114-
<![CDATA[
115-
pattern of the formatter is : MM/dd/yyyy
116-
First Formatted output with pattern is 12/31/1969
117-
Now pattern of the formatter is : yyyymmdd hh:mm:ss z
118-
Second Formatted output with pattern is 19690031 04:00:00 PST
110+
&example.outputs;
111+
<screen>
112+
<![CDATA[
113+
Pattern of the formatter is : MM/dd/yyyy
114+
First Formatted output is 12/31/1969
115+
Now pattern of the formatter is : yyyyMMdd hh:mm:ss z
116+
Second Formatted output is 19691231 04:00:00 PST
119117
]]>
120-
</screen>
118+
</screen>
121119
</refsect1>
122120

123121
<refsect1 role="seealso">

0 commit comments

Comments
 (0)