Skip to content

Commit 016b60a

Browse files
committed
Add examples for formatOptions
1 parent 85a7d73 commit 016b60a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

core/src/components/datetime-button/test/basic/index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,41 @@ <h2>preferWheel / date-time</h2>
215215
></ion-datetime>
216216
</ion-popover>
217217
</div>
218+
219+
<div class="grid-item">
220+
<h2>formatOptions</h2>
221+
222+
<ion-item>
223+
<ion-label>Start Date</ion-label>
224+
<ion-datetime-button datetime="format-options" slot="end"></ion-datetime-button>
225+
</ion-item>
226+
227+
<ion-popover arrow="false">
228+
<ion-datetime
229+
id="format-options"
230+
presentation="date-time"
231+
value="2023-11-02T01:22:00"
232+
locale="en-US"
233+
></ion-datetime>
234+
</ion-popover>
235+
</div>
218236
</div>
219237
</ion-content>
220238
</ion-app>
221239
</body>
240+
241+
<script>
242+
const formatOptionsDatetime = document.querySelector('#format-options');
243+
formatOptionsDatetime.formatOptions = {
244+
date: {
245+
weekday: 'short',
246+
month: 'long',
247+
day: '2-digit',
248+
},
249+
time: {
250+
hour: '2-digit',
251+
minute: '2-digit',
252+
},
253+
};
254+
</script>
222255
</html>

core/src/components/datetime/test/basic/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ <h2>Modal - Custom</h2>
308308
</ion-datetime>
309309
</ion-modal>
310310
</div>
311+
312+
<div class="grid-item">
313+
<h2>formatOptions</h2>
314+
<ion-datetime value="2020-03-14T14:23:00.000Z" id="format-options-datetime">
315+
<span slot="title">Select Date</span>
316+
</ion-datetime>
317+
</div>
311318
</div>
312319
</ion-content>
313320
<script>
@@ -403,6 +410,12 @@ <h2>Modal - Custom</h2>
403410
app.appendChild(modalElement);
404411
return modalElement;
405412
};
413+
414+
const formatOptions = document.querySelector('#format-options-datetime');
415+
formatOptions.formatOptions = {
416+
time: { hour: '2-digit', minute: '2-digit' },
417+
date: { day: '2-digit', month: 'long', era: 'short' },
418+
};
406419
</script>
407420
</ion-app>
408421
</body>

0 commit comments

Comments
 (0)