Skip to content

Commit

Permalink
feat: added dayFormat prop
Browse files Browse the repository at this point in the history
Co-Authored-by: Nerijus Gaidjurgis <[email protected]>
  • Loading branch information
icehaunter and nerijusgaidjurgis committed Jun 4, 2023
1 parent f8fc91d commit e567369
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Full props documentation is available at https://icehaunter.github.io/vue3-datep
| `startingView` | `'time' \| 'day' \| 'month' \| 'year'` | `'day'` | View on which the date picker should open. Can be either `year`, `month`, or `day` |
| `minimumView` | `'time' \| 'day' \| 'month' \| 'year'` | `'day'` | If set, lower-level views won't show |
| `dayPickerHeadingFormat` | `String` | `LLLL yyyy` | `date-fns`-type formatting for a day view heading |
| `dayFormat` | `String` | `dd` | `date-fns`-type formatting for each day on the day view |
| `weekdayFormat` | `String` | `EE` | `date-fns`-type formatting for a line of weekdays on day view |
| `inputFormat` | `String` | `yyyy-MM-dd` | `date-fns`-type format in which the string in the input should be both parsed and displayed |
| `locale` | [`Locale`](https://date-fns.org/v2.16.1/docs/I18n#usage) | `date-fns/locale/en` | [`date-fns` locale object](https://date-fns.org/v2.16.1/docs/I18n#usage). Used in string formatting (see default `dayPickerHeadingFormat`) |
Expand Down
7 changes: 7 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ View on which the date picker should open. Can be either `year`, `month`, `day`

`date-fns`-type formatting for a line of weekdays on day view. By default uses three-letter representation (e.g. Fri).

### `dayFormat`

- Type: `String` (date-fns [format string](https://date-fns.org/docs/format))
- Default: `dd`

`date-fns`-type formatting for the day picker view.

### `inputFormat`

- Type: `String` (date-fns [format string](https://date-fns.org/docs/format))
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ More in-depth documentation of the props, as well as examples, can be found in [
| `startingView` | `'time' \| `'day' \| 'month' \| 'year'` | `'day'` | View on which the date picker should open. Can be either `year`, `month`, or `day` |
| `minimumView` | `'time' \| `'day' \| 'month' \| 'year'` | `'day'` | If set, lower-level views won't show |
| `dayPickerHeadingFormat` | `String` | `LLLL yyyy` | `date-fns`-type formatting for a day view heading |
| `dayFormat` | `String` | `dd` | `date-fns`-type formatting for each day on the day view |
| `weekdayFormat` | `String` | `EE` | `date-fns`-type formatting for a line of weekdays on day view |
| `inputFormat` | `String` | `yyyy-MM-dd` | `date-fns`-type format in which the string in the input should be both parsed and displayed |
| `locale` | [`Locale`](https://date-fns.org/v2.16.1/docs/I18n#usage) | `date-fns/locale/en` | [`date-fns` locale object](https://date-fns.org/v2.16.1/docs/I18n#usage). Used in string formatting (see default `dayPickerHeadingFormat`) |
Expand Down
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:upperLimit="to"
:lowerLimit="from"
:clearable="true"
dayFormat="d"
:disabledDates="{ predicate: isToday }"
>
<template v-slot:clear="{ onClear }">
Expand Down
9 changes: 9 additions & 0 deletions src/datepicker/Datepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
:locale="locale"
:weekdayFormat="weekdayFormat"
:allow-outside-interval="allowOutsideInterval"
:format="dayFormat"
@select="selectDay"
@back="viewShown = 'month'"
/>
Expand Down Expand Up @@ -196,6 +197,14 @@ export default defineComponent({
required: false,
default: 'EE',
},
/**
* `date-fns`-type formatting for the day picker view
*/
dayFormat: {
type: String,
required: false,
default: 'dd',
},
/**
* `date-fns`-type format in which the string in the input should be both
* parsed and displayed
Expand Down

0 comments on commit e567369

Please sign in to comment.