-
Notifications
You must be signed in to change notification settings - Fork 3.1k
docs(datetime, datetime-button): document formatOptions property #3452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f74ec55
docs(datetime,datetime-button): document formatOptions property
mapsandapps 9ab2baa
misc improvements
mapsandapps 0d40670
Apply suggestions from code review
mapsandapps 3458632
add link to time zone docs
mapsandapps 100cec6
enlarge playground
mapsandapps 7a8b2ef
Merge branch 'FW-5860' of github.com:ionic-team/ionic-docs into FW-5860
mapsandapps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
```html | ||
<ion-datetime-button datetime="datetime"></ion-datetime-button> | ||
|
||
<ion-modal [keepContentsMounted]="true"> | ||
<ng-template> | ||
<ion-datetime | ||
id="datetime" | ||
presentation="date-time" | ||
value="2023-11-02T01:22:00" | ||
[formatOptions]="{ | ||
date: { | ||
weekday: 'short', | ||
month: 'long', | ||
day: '2-digit', | ||
}, | ||
time: { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
}" | ||
></ion-datetime> | ||
</ng-template> | ||
</ion-modal> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Datetime Button</title> | ||
<link rel="stylesheet" href="../../../common.css" /> | ||
<script src="../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" /> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-datetime-button datetime="datetime"></ion-datetime-button> | ||
|
||
<ion-modal keep-contents-mounted="{true}"> | ||
<ion-datetime id="datetime" presentation="date-time" value="2023-11-02T01:22:00"></ion-datetime> | ||
</ion-modal> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.formatOptions = { | ||
date: { | ||
weekday: 'short', | ||
month: 'long', | ||
day: '2-digit', | ||
}, | ||
time: { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
import angular from './angular.md'; | ||
|
||
<Playground | ||
version="7" | ||
size="large" | ||
code={{ | ||
mapsandapps marked this conversation as resolved.
Show resolved
Hide resolved
|
||
javascript, | ||
react, | ||
vue, | ||
angular, | ||
}} | ||
src="usage/v7/datetime-button/format-options/demo.html" | ||
/> |
22 changes: 22 additions & 0 deletions
22
static/usage/v7/datetime-button/format-options/javascript.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
```html | ||
<ion-datetime-button datetime="datetime"></ion-datetime-button> | ||
|
||
<ion-modal keep-contents-mounted="true"> | ||
<ion-datetime id="datetime" presentation="date-time" value="2023-11-02T01:22:00"></ion-datetime> | ||
</ion-modal> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.formatOptions = { | ||
date: { | ||
weekday: 'short', | ||
month: 'long', | ||
day: '2-digit', | ||
}, | ||
time: { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
}; | ||
</script> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
```tsx | ||
import React from 'react'; | ||
import { IonDatetime, IonDatetimeButton, IonModal } from '@ionic/react'; | ||
|
||
function Example() { | ||
return ( | ||
<> | ||
<IonDatetimeButton datetime="datetime"></IonDatetimeButton> | ||
|
||
<IonModal keepContentsMounted={true}> | ||
<IonDatetime | ||
id="datetime" | ||
presentation="date-time" | ||
value="2023-11-02T01:22:00" | ||
formatOptions={{ | ||
date: { | ||
weekday: 'short', | ||
month: 'long', | ||
day: '2-digit', | ||
}, | ||
time: { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
}} | ||
></IonDatetime> | ||
</IonModal> | ||
</> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```html | ||
<template> | ||
<ion-datetime-button datetime="datetime"></ion-datetime-button> | ||
|
||
<ion-modal :keep-contents-mounted="true"> | ||
<ion-datetime | ||
id="datetime" | ||
presentation="date-time" | ||
value="2023-11-02T01:22:00" | ||
:format-options="formatOptions" | ||
></ion-datetime> | ||
</ion-modal> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { IonDatetime, IonDatetimeButton, IonModal } from '@ionic/vue'; | ||
import { defineComponent } from 'vue'; | ||
|
||
const formatOptions = { | ||
date: { | ||
weekday: 'short', | ||
month: 'long', | ||
day: '2-digit', | ||
}, | ||
time: { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
}, | ||
}; | ||
</script> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```html | ||
<ion-datetime | ||
value="2023-11-02T01:22:00" | ||
[formatOptions]="{ | ||
time: { hour: '2-digit', minute: '2-digit' }, | ||
date: { day: '2-digit', month: 'long' }, | ||
}" | ||
> | ||
<span slot="title">Select Date</span> | ||
</ion-datetime> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Datetime</title> | ||
<link rel="stylesheet" href="../../../common.css" /> | ||
<script src="../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" /> | ||
<style> | ||
ion-datetime { | ||
width: 350px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-content> | ||
<div class="container"> | ||
<ion-datetime value="2023-11-02T01:22:00"> | ||
<span slot="title">Select Date</span> | ||
</ion-datetime> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.formatOptions = { | ||
time: { hour: '2-digit', minute: '2-digit' }, | ||
date: { day: '2-digit', month: 'long' }, | ||
}; | ||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Playground from '@site/src/components/global/Playground'; | ||
|
||
import javascript from './javascript.md'; | ||
import react from './react.md'; | ||
import vue from './vue.md'; | ||
import angular from './angular.md'; | ||
|
||
<Playground | ||
version="7" | ||
size="large" | ||
code={{ | ||
javascript, | ||
react, | ||
vue, | ||
angular, | ||
}} | ||
src="usage/v7/datetime/format-options/demo.html" | ||
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
```html | ||
<ion-datetime value="2023-11-02T01:22:00"> | ||
<span slot="title">Select Date</span> | ||
</ion-datetime> | ||
|
||
<script> | ||
const datetime = document.querySelector('ion-datetime'); | ||
datetime.formatOptions = { | ||
time: { hour: '2-digit', minute: '2-digit' }, | ||
date: { day: '2-digit', month: 'long' }, | ||
}; | ||
</script> | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
```tsx | ||
import React from 'react'; | ||
import { IonDatetime } from '@ionic/react'; | ||
|
||
function Example() { | ||
return ( | ||
<IonDatetime | ||
value="2023-11-02T01:22:00" | ||
formatOptions={{ | ||
time: { hour: '2-digit', minute: '2-digit' }, | ||
date: { day: '2-digit', month: 'long' }, | ||
}} | ||
> | ||
<span slot="title">Select Date</span> | ||
</IonDatetime> | ||
); | ||
} | ||
export default Example; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```html | ||
<template> | ||
<ion-datetime value="2023-11-02T01:22:00" :format-options="formatOptions"> | ||
<span slot="title">Select Date</span> | ||
</ion-datetime> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { IonDatetime } from '@ionic/vue'; | ||
import { defineComponent } from 'vue'; | ||
|
||
const formatOptions = { | ||
time: { hour: '2-digit', minute: '2-digit' }, | ||
date: { day: '2-digit', month: 'long' }, | ||
}; | ||
</script> | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: I could be totally wrong, but I feel like most of the time using either
dateStyle
ortimeStyle
will be what most devs want here since it lets you quickly do things like02/15/2024
. Perhaps we can make that suggestion? I'm fine not doing this if you think it would be more confusing than helpful.