Skip to content

Commit 349d11b

Browse files
author
Nathan Reyes
committed
Fixes Turkish locale. Fixes weekday formatting (Closes #104).
2 parents b9da5cc + 03790b6 commit 349d11b

File tree

6 files changed

+61
-40
lines changed

6 files changed

+61
-40
lines changed

CHANGELOG.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,45 @@
1+
# v0.9.0
12
## Bug Fixes
3+
### `v-calendar`
4+
* Fixes Turkish locale identifier
5+
* Fixes weekday formatting by using UNC dates with `Intl.DateTimeFormat`. Closes #104.
6+
* Other small bug fixes
7+
28
### `v-date-picker`
3-
* Fixed glitch with highlight cap animation when `mode === "range"`
4-
* Fixed bug with `themeStyles.dayContent` style getting ignored. Closes #115.
9+
* Fixes glitch with highlight cap animation when `mode === "range"`
10+
* Fixes bug with `themeStyles.dayContent` style getting ignored. Closes #115.
511

612
## Improvements
713
### `v-calendar`
8-
* Added `min-date` prop as a convenient alternative to `min-page`
9-
* Added `max-date` prop as a convenient alternative to `max-page`
10-
* Added `is-linked` prop to link panes to consecutive months when `is-double-paned` is set. Closes #80.
11-
* Added `is-vertical` prop for vertical calendar orientation when `is-double-paned` is set. Closes #89.
14+
* Adds `min-date` prop as a convenient alternative to `min-page`
15+
* Adds `max-date` prop as a convenient alternative to `max-page`
16+
* Adds `is-linked` prop to link panes to consecutive months when `is-double-paned` is set. Closes #80.
17+
* Adds `is-vertical` prop for vertical calendar orientation when `is-double-paned` is set. Closes #89.
18+
19+
### `v-date-picker`
20+
* `min-date` and `max-date` props are now forwarded to `v-calendar`. Closes #78.
1221

1322
### Defaults
1423
Theme styles modifications. Closes #93.
1524

1625
| Style | Modification | Description |
1726
| ----- | ------------ | ----- |
18-
| `horizontalDivider` | Added | Horizontal divider when calendars are in vertical orientation (`is-vertical`) |
19-
| `navHeader` | Added | Navigation pane header. |
20-
| `navHeaderTitle` | Added | Navigation pane header title. |
21-
| `navHeaderArrows` | Added | Navigation pane header arrows. |
22-
| `navMonthCell` | Added | Navigation pane month cells. |
23-
| `navYearCell` | Added | Navigation pane year cells. |
27+
| `horizontalDivider` | Add | Horizontal divider when calendars are in vertical orientation (`is-vertical`) |
28+
| `navHeader` | Add | Navigation pane header. |
29+
| `navHeaderTitle` | Add | Navigation pane header title. |
30+
| `navHeaderArrows` | Add | Navigation pane header arrows. |
31+
| `navMonthCell` | Add | Navigation pane month cells. |
32+
| `navYearCell` | Add | Navigation pane year cells. |
2433
| `header` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
25-
| `headerTitle` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
26-
| `headerArrows` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
27-
| `headerHorizontalDivider` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
28-
| `weekdays` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
29-
| `weekdaysHorizontalDivider` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
30-
| `weeks` | Edited | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
31-
| ~~`headerVerticalDivider`~~ | Removed | *Reference note below* |
32-
| ~~`weekdaysVerticalDivider`~~ | Removed | *Reference note below* |
33-
| ~~`weeksVerticalDivider`~~ | Removed | *Reference note below* |
34+
| `headerTitle` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
35+
| `headerArrows` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
36+
| `headerHorizontalDivider` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
37+
| `weekdays` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
38+
| `weekdaysHorizontalDivider` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
39+
| `weeks` | Edit | Supports use of function that accepts a [`page`](https://docs.vcalendar.io/api#page-object) object and return a style |
40+
| ~~`headerVerticalDivider`~~ | Remove | *Reference note below* |
41+
| ~~`weekdaysVerticalDivider`~~ | Remove | *Reference note below* |
42+
| ~~`weeksVerticalDivider`~~ | Remove | *Reference note below* |
3443

3544
* Styles removed in favor of defining functions for the `header`, `weekdays` and `weeks` styles like so...
3645

@@ -59,9 +68,6 @@ export default {
5968
}
6069
```
6170

62-
### `v-date-picker`
63-
* `min-date` and `max-date` props are now forwarded to `v-calendar`. Closes #78.
64-
6571
# v0.8.0
6672
## Bug Fixes
6773
### `v-date-picker`

src/components/Calendar.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,28 @@ export default {
174174
this.fromPage_ = getPrevPage(val);
175175
},
176176
isDoublePaned_() {
177-
this.refreshContainerWidth();
177+
this.refreshIsConstrained();
178178
this.refreshToPage();
179179
},
180+
isLinked(val) {
181+
if (val) this.toPage_ = getNextPage(this.fromPage_);
182+
},
180183
isExpanded() {
181-
this.refreshContainerWidth();
184+
this.refreshIsConstrained();
182185
},
183186
},
184187
created() {
185188
this.refreshFromPage();
186189
this.refreshToPage();
187190
},
188191
mounted() {
189-
this.refreshContainerWidth();
190-
window.addEventListener('resize', this.refreshContainerWidth);
192+
this.$nextTick(() => {
193+
this.refreshIsConstrained();
194+
window.addEventListener('resize', this.refreshIsConstrained);
195+
});
191196
},
192197
beforeDestroy() {
193-
window.removeEventListener('resize', this.refreshContainerWidth);
198+
window.removeEventListener('resize', this.refreshIsConstrained);
194199
},
195200
methods: {
196201
refreshFromPage() {
@@ -212,7 +217,7 @@ export default {
212217
getNextPage(this.minPage_),
213218
);
214219
},
215-
refreshContainerWidth() {
220+
refreshIsConstrained() {
216221
// Only test for constrained environment if needed
217222
if (!window || !this.isDoublePaned || this.isVertical) {
218223
this.isConstrained = false;

src/components/CalendarDay.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export default {
248248
return this.popoverState.isInteractive;
249249
},
250250
contentStyle() {
251-
// if (this.styles.dayContent) console.log(this.styles.dayContent);
252251
const userStyle = this.styles.dayContent;
253252
const disableEvents =
254253
this.dayCellStyle &&

src/components/CalendarPane.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ export default {
209209
);
210210
},
211211
weekdayLabels() {
212-
return getWeekdayDates(defaults.firstDayOfWeek).map(d =>
213-
format(d, this.formats.weekdays || 'WW'),
212+
return getWeekdayDates({ firstDayOfWeek: defaults.firstDayOfWeek }).map(
213+
d => format(d, this.formats.weekdays || 'WW'),
214214
);
215215
},
216216
titleClass() {

src/utils/helpers.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ export const getMonthDates = (year = 2000) => {
5353
return dates;
5454
};
5555

56-
export const getWeekdayDates = (firstDayOfWeek = 1, year = 2000) => {
56+
export const getWeekdayDates = ({
57+
firstDayOfWeek = 1,
58+
year = 2000,
59+
utc = false,
60+
}) => {
5761
const dates = [];
5862
for (let i = 1, j = 0; j < 7; i++) {
59-
const d = new Date(year, 0, i);
60-
if (d.getDay() === firstDayOfWeek - 1 || j > 0) {
63+
const d = utc ? new Date(Date.UTC(year, 0, i)) : new Date(year, 0, i);
64+
const day = utc ? d.getUTCDay() : d.getDay();
65+
if (day === firstDayOfWeek - 1 || j > 0) {
6166
dates.push(d);
6267
j++;
6368
}

src/utils/locales.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,25 @@ const locales = {
7171
// Thai
7272
th: { L: 'DD/MM/YYYY' },
7373
// Turkish
74-
tk: { dow: 2, L: 'DD.MM.YYYY' },
74+
tr: { dow: 2, L: 'DD.MM.YYYY' },
7575
};
7676
locales.en = locales['en-US'];
7777
locales.zh = locales['zh-CN'];
7878

7979
// Month and day names are derived from Intl.DateTimeFormat
8080
const getMonthNames = (locale, length) => {
81-
const dtf = new Intl.DateTimeFormat(locale, { month: length });
81+
const dtf = new Intl.DateTimeFormat(locale, {
82+
month: length,
83+
timezome: 'UTC',
84+
});
8285
return getMonthDates().map(d => dtf.format(d));
8386
};
8487
const getDayNames = (locale, length) => {
85-
const dtf = new Intl.DateTimeFormat(locale, { weekday: length });
86-
return getWeekdayDates().map(d => dtf.format(d));
88+
const dtf = new Intl.DateTimeFormat(locale, {
89+
weekday: length,
90+
timeZone: 'UTC',
91+
});
92+
return getWeekdayDates({ utc: true }).map(d => dtf.format(d));
8793
};
8894

8995
export default (locale, defaults) => {

0 commit comments

Comments
 (0)