Skip to content

Commit 3a8c3e7

Browse files
authored
Enable runnable (WASM) examples for datetime (#4887)
* Enable runnable (WASM) examples for datetime
1 parent bb54309 commit 3a8c3e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+365
-296
lines changed

reference/datetime/book.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
33

4-
<book xml:id="book.datetime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4+
<book xml:id="book.datetime" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
55
<?phpdoc extension-membership="core"?>
66
<title>Date and Time</title>
77
<titleabbrev>Date/Time</titleabbrev>

reference/datetime/dateinterval/construct.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,9 @@ echo $interval->format("%d");
188188
</programlisting>
189189
&example.outputs;
190190
<screen role="php">
191+
<![CDATA[
191192
7
193+
]]>
192194
</screen>
193195
</example>
194196
</para>
@@ -199,11 +201,8 @@ echo $interval->format("%d");
199201
<programlisting role="php">
200202
<![CDATA[
201203
<?php
202-
203204
$interval = new DateInterval('P1W2D');
204205
var_dump($interval);
205-
206-
?>
207206
]]>
208207
</programlisting>
209208
&example.outputs.82;

reference/datetime/dateinterval/createfromdatestring.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<para>
107107
<example>
108108
<title>Parsing valid date intervals</title>
109-
<programlisting role="php">
109+
<programlisting role="php" annotations="non-interactive">
110110
<![CDATA[
111111
<?php
112112
// Each set of intervals is equal.
@@ -130,7 +130,6 @@ $i = DateInterval::createFromDateString('1 day + 12 hours');
130130
131131
$i = new DateInterval('PT3600S');
132132
$i = DateInterval::createFromDateString('3600 seconds');
133-
?>
134133
]]>
135134
</programlisting>
136135
</example>
@@ -146,13 +145,14 @@ echo $i->format('%d %h %i'), "\n";
146145
147146
$i = DateInterval::createFromDateString('1 year - 10 days');
148147
echo $i->format('%y %d'), "\n";
149-
?>
150148
]]>
151149
</programlisting>
152150
&example.outputs;
153-
<screen role="shell">
151+
<screen>
152+
<![CDATA[
154153
449 2 70
155154
1 -10
155+
]]>
156156
</screen>
157157
</example>
158158
</para>

reference/datetime/dateinterval/format.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,8 @@
185185
<programlisting role="php">
186186
<![CDATA[
187187
<?php
188-
189188
$interval = new DateInterval('P2Y4DT6H8M');
190189
echo $interval->format('%d days');
191-
192-
?>
193190
]]>
194191
</programlisting>
195192
&example.outputs;
@@ -206,11 +203,8 @@ echo $interval->format('%d days');
206203
<programlisting role="php">
207204
<![CDATA[
208205
<?php
209-
210206
$interval = new DateInterval('P32D');
211207
echo $interval->format('%d days');
212-
213-
?>
214208
]]>
215209
</programlisting>
216210
&example.outputs;
@@ -230,7 +224,6 @@ echo $interval->format('%d days');
230224
<programlisting role="php">
231225
<![CDATA[
232226
<?php
233-
234227
$january = new DateTime('2010-01-01');
235228
$february = new DateTime('2010-02-01');
236229
$interval = $february->diff($january);
@@ -241,8 +234,6 @@ echo $interval->format('%a total days')."\n";
241234
// While %d will only output the number of days not already covered by the
242235
// month.
243236
echo $interval->format('%m month, %d days');
244-
245-
?>
246237
]]>
247238
</programlisting>
248239
&example.outputs;

reference/datetime/dateperiod.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@
162162
<para>
163163
<informalexample>
164164
<programlisting role="php">
165-
<![CDATA[<?php
165+
<![CDATA[
166+
<?php
166167
$start = new DateTime('2018-12-31 00:00:00');
167168
$end = new DateTime('2021-12-31 00:00:00');
168169
$interval = new DateInterval('P1M');
@@ -184,15 +185,17 @@ echo $period->recurrences, "\n";
184185
185186
$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
186187
echo $period->recurrences, "\n";
187-
?>]]>
188+
]]>
188189
</programlisting>
189190
&example.outputs;
190191
<screen role="php">
192+
<![CDATA[
191193
5
192194
6
193195
7
194196
1
195197
0
198+
]]>
196199
</screen>
197200
</informalexample>
198201
</para>

reference/datetime/dateperiod/construct.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ $period = new DatePeriod($iso);
210210
foreach ($period as $date) {
211211
echo $date->format('Y-m-d')."\n";
212212
}
213-
?>
214213
]]>
215214
</programlisting>
216215
&example.outputs;
217216
<screen>
218217
<![CDATA[
218+
Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in script on line 11
219219
2012-07-01
220220
2012-07-08
221221
2012-07-15
@@ -244,7 +244,6 @@ $period = new DatePeriod($start, $interval, $end,
244244
foreach ($period as $date) {
245245
echo $date->format('Y-m-d')."\n";
246246
}
247-
?>
248247
]]>
249248
</programlisting>
250249
&example.outputs;
@@ -273,7 +272,6 @@ $period = new DatePeriod($begin, $interval, $end, DatePeriod::EXCLUDE_START_DATE
273272
foreach ($period as $dt) {
274273
echo $dt->format('l Y-m-d'), "\n";
275274
}
276-
?>
277275
]]>
278276
</programlisting>
279277
&example.outputs;

reference/datetime/dateperiod/createfromiso8601string.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,13 @@
122122
<![CDATA[
123123
<?php
124124
$iso = 'R4/2023-07-01T00:00:00Z/P7D';
125-
126125
$period = DatePeriod::createFromISO8601String($iso);
127126
128127
// By iterating over the DatePeriod object, all of the
129128
// recurring dates within that period are printed.
130129
foreach ($period as $date) {
131130
echo $date->format('Y-m-d'), "\n";
132131
}
133-
?>
134132
]]>
135133
</programlisting>
136134
&example.outputs;

reference/datetime/dateperiod/getdateinterval.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@
4040
<programlisting role="php">
4141
<![CDATA[
4242
<?php
43-
$period = new DatePeriod('R7/2016-05-16T00:00:00Z/P1D');
43+
$period = DatePeriod::createFromIso8601String('R7/2016-05-16T00:00:00Z/P1D');
4444
$interval = $period->getDateInterval();
4545
echo $interval->format('%d day');
46-
?>
4746
]]>
4847
</programlisting>
4948
&example.outputs;

reference/datetime/dateperiod/getenddate.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ $period = new DatePeriod(
6060
);
6161
$start = $period->getEndDate();
6262
echo $start->format(DateTime::ISO8601);
63-
?>
6463
]]>
6564
</programlisting>
6665
&examples.outputs;
@@ -81,7 +80,6 @@ $period = new DatePeriod(
8180
7
8281
);
8382
var_dump($period->getEndDate());
84-
?>
8583
]]>
8684
</programlisting>
8785
&example.outputs;

reference/datetime/dateperiod/getrecurrences.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
&reftitle.returnvalues;
2828
<para>
2929
The number of recurrences as set by explicitly passing the
30-
<literal>$recurrences</literal> to the contructor of the
30+
<literal>$recurrences</literal> to the constructor of the
3131
<classname>DatePeriod</classname> class, or &null; otherwise.
3232
</para>
3333
</refsect1>
@@ -38,7 +38,8 @@
3838
<example>
3939
<title>Different values for <methodname>DatePeriod::getRecurrences</methodname></title>
4040
<programlisting role="php">
41-
<![CDATA[<?php
41+
<![CDATA[
42+
<?php
4243
$start = new DateTime('2018-12-31 00:00:00');
4344
$end = new DateTime('2021-12-31 00:00:00');
4445
$interval = new DateInterval('P1M');
@@ -60,16 +61,18 @@ var_dump($period->getRecurrences());
6061
6162
$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
6263
var_dump($period->getRecurrences());
63-
?>]]>
64+
]]>
6465
</programlisting>
6566
&example.outputs;
6667
<screen role="php">
68+
<![CDATA[
6769
5
6870
5
6971
5
7072
7173
NULL
7274
NULL
75+
]]>
7376
</screen>
7477
</example>
7578
</para>

0 commit comments

Comments
 (0)