@instructure/ui-calendar 10.3.1-snapshot-0 → 10.3.1-snapshot-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -2
- package/es/Calendar/index.js +15 -1
- package/lib/Calendar/index.js +15 -1
- package/package.json +20 -20
- package/src/Calendar/README.md +30 -4
- package/src/Calendar/index.tsx +17 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Calendar/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.3.1-snapshot-
|
|
6
|
+
## [10.3.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v10.3.0...v10.3.1-snapshot-3) (2024-10-09)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-calendar:** fix duplicate dates for certain timezones ([f9181aa](https://github.com/instructure/instructure-ui/commit/f9181aa88c35eba1e374240505d32bf618c46b04))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Calendar/index.js
CHANGED
|
@@ -336,7 +336,21 @@ let Calendar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
336
336
|
const currDate = DateTime.getFirstDayOfWeek(visibleMonth.clone().startOf('month'));
|
|
337
337
|
const arr = [];
|
|
338
338
|
for (let i = 0; i < Calendar.DAY_COUNT; i++) {
|
|
339
|
-
|
|
339
|
+
// This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
|
|
340
|
+
// in these cases adding 1 day results in 23 hours added instead,
|
|
341
|
+
// so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
|
|
342
|
+
// in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
|
|
343
|
+
// which would cause duplicate dates in the calendar.
|
|
344
|
+
// More info on the bug: https://github.com/moment/moment/issues/4743
|
|
345
|
+
// Please note that this causes one hour of time difference in the affected timezones/dates and to
|
|
346
|
+
// fully solve this bug we need to change to something like luxon which handles this properly
|
|
347
|
+
if (currDate.clone().format('HH') === '23') {
|
|
348
|
+
arr.push(currDate.clone().add({
|
|
349
|
+
hours: 1
|
|
350
|
+
}));
|
|
351
|
+
} else {
|
|
352
|
+
arr.push(currDate.clone());
|
|
353
|
+
}
|
|
340
354
|
currDate.add({
|
|
341
355
|
days: 1
|
|
342
356
|
});
|
package/lib/Calendar/index.js
CHANGED
|
@@ -347,7 +347,21 @@ let Calendar = exports.Calendar = (_dec = (0, _emotion.withStyle)(_styles.defaul
|
|
|
347
347
|
const currDate = _DateTime.DateTime.getFirstDayOfWeek(visibleMonth.clone().startOf('month'));
|
|
348
348
|
const arr = [];
|
|
349
349
|
for (let i = 0; i < Calendar.DAY_COUNT; i++) {
|
|
350
|
-
|
|
350
|
+
// This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
|
|
351
|
+
// in these cases adding 1 day results in 23 hours added instead,
|
|
352
|
+
// so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
|
|
353
|
+
// in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
|
|
354
|
+
// which would cause duplicate dates in the calendar.
|
|
355
|
+
// More info on the bug: https://github.com/moment/moment/issues/4743
|
|
356
|
+
// Please note that this causes one hour of time difference in the affected timezones/dates and to
|
|
357
|
+
// fully solve this bug we need to change to something like luxon which handles this properly
|
|
358
|
+
if (currDate.clone().format('HH') === '23') {
|
|
359
|
+
arr.push(currDate.clone().add({
|
|
360
|
+
hours: 1
|
|
361
|
+
}));
|
|
362
|
+
} else {
|
|
363
|
+
arr.push(currDate.clone());
|
|
364
|
+
}
|
|
351
365
|
currDate.add({
|
|
352
366
|
days: 1
|
|
353
367
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-calendar",
|
|
3
|
-
"version": "10.3.1-snapshot-
|
|
3
|
+
"version": "10.3.1-snapshot-3",
|
|
4
4
|
"description": "A calendar component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,31 +23,31 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "10.3.1-snapshot-
|
|
27
|
-
"@instructure/ui-color-utils": "10.3.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-locator": "10.3.1-snapshot-
|
|
29
|
-
"@instructure/ui-test-utils": "10.3.1-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "10.3.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "10.3.1-snapshot-3",
|
|
27
|
+
"@instructure/ui-color-utils": "10.3.1-snapshot-3",
|
|
28
|
+
"@instructure/ui-test-locator": "10.3.1-snapshot-3",
|
|
29
|
+
"@instructure/ui-test-utils": "10.3.1-snapshot-3",
|
|
30
|
+
"@instructure/ui-themes": "10.3.1-snapshot-3",
|
|
31
31
|
"@testing-library/jest-dom": "^6.4.6",
|
|
32
32
|
"@testing-library/react": "^16.0.1",
|
|
33
33
|
"vitest": "^2.1.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.25.6",
|
|
37
|
-
"@instructure/console": "10.3.1-snapshot-
|
|
38
|
-
"@instructure/emotion": "10.3.1-snapshot-
|
|
39
|
-
"@instructure/shared-types": "10.3.1-snapshot-
|
|
40
|
-
"@instructure/ui-a11y-content": "10.3.1-snapshot-
|
|
41
|
-
"@instructure/ui-buttons": "10.3.1-snapshot-
|
|
42
|
-
"@instructure/ui-i18n": "10.3.1-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "10.3.1-snapshot-
|
|
44
|
-
"@instructure/ui-prop-types": "10.3.1-snapshot-
|
|
45
|
-
"@instructure/ui-react-utils": "10.3.1-snapshot-
|
|
46
|
-
"@instructure/ui-simple-select": "10.3.1-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "10.3.1-snapshot-
|
|
48
|
-
"@instructure/ui-utils": "10.3.1-snapshot-
|
|
49
|
-
"@instructure/ui-view": "10.3.1-snapshot-
|
|
50
|
-
"@instructure/uid": "10.3.1-snapshot-
|
|
37
|
+
"@instructure/console": "10.3.1-snapshot-3",
|
|
38
|
+
"@instructure/emotion": "10.3.1-snapshot-3",
|
|
39
|
+
"@instructure/shared-types": "10.3.1-snapshot-3",
|
|
40
|
+
"@instructure/ui-a11y-content": "10.3.1-snapshot-3",
|
|
41
|
+
"@instructure/ui-buttons": "10.3.1-snapshot-3",
|
|
42
|
+
"@instructure/ui-i18n": "10.3.1-snapshot-3",
|
|
43
|
+
"@instructure/ui-icons": "10.3.1-snapshot-3",
|
|
44
|
+
"@instructure/ui-prop-types": "10.3.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-react-utils": "10.3.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-simple-select": "10.3.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-testable": "10.3.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-utils": "10.3.1-snapshot-3",
|
|
49
|
+
"@instructure/ui-view": "10.3.1-snapshot-3",
|
|
50
|
+
"@instructure/uid": "10.3.1-snapshot-3",
|
|
51
51
|
"prop-types": "^15.8.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
package/src/Calendar/README.md
CHANGED
|
@@ -162,8 +162,21 @@ basic `Calendar` might be created using utilities from
|
|
|
162
162
|
|
|
163
163
|
return Array.apply(null, Array(Calendar.DAY_COUNT)).map(() => {
|
|
164
164
|
const currentDate = date.clone()
|
|
165
|
-
date.add(1
|
|
166
|
-
|
|
165
|
+
date.add({days: 1})
|
|
166
|
+
|
|
167
|
+
// This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
|
|
168
|
+
// in these cases adding 1 day results in 23 hours added instead,
|
|
169
|
+
// so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
|
|
170
|
+
// in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
|
|
171
|
+
// which would cause duplicate dates in the calendar.
|
|
172
|
+
// More info on the bug: https://github.com/moment/moment/issues/4743
|
|
173
|
+
// Please note that this causes one hour of time difference in the affected timezones/dates and to
|
|
174
|
+
// fully solve this bug we need to change to something like luxon which handles this properly
|
|
175
|
+
if (currentDate.clone().format('HH') === '23') {
|
|
176
|
+
return currentDate.clone().add({hours: 1})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return currentDate.clone()
|
|
167
180
|
})
|
|
168
181
|
}
|
|
169
182
|
|
|
@@ -274,8 +287,21 @@ basic `Calendar` might be created using utilities from
|
|
|
274
287
|
|
|
275
288
|
return Array.apply(null, Array(Calendar.DAY_COUNT)).map(() => {
|
|
276
289
|
const currentDate = date.clone()
|
|
277
|
-
date.add(1
|
|
278
|
-
|
|
290
|
+
date.add({days: 1})
|
|
291
|
+
|
|
292
|
+
// This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
|
|
293
|
+
// in these cases adding 1 day results in 23 hours added instead,
|
|
294
|
+
// so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
|
|
295
|
+
// in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
|
|
296
|
+
// which would cause duplicate dates in the calendar.
|
|
297
|
+
// More info on the bug: https://github.com/moment/moment/issues/4743
|
|
298
|
+
// Please note that this causes one hour of time difference in the affected timezones/dates and to
|
|
299
|
+
// fully solve this bug we need to change to something like luxon which handles this properly
|
|
300
|
+
if (currentDate.clone().format('HH') === '23') {
|
|
301
|
+
return currentDate.clone().add({hours: 1})
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return currentDate.clone()
|
|
279
305
|
})
|
|
280
306
|
}
|
|
281
307
|
|
package/src/Calendar/index.tsx
CHANGED
|
@@ -499,10 +499,25 @@ class Calendar extends Component<CalendarProps, CalendarState> {
|
|
|
499
499
|
const currDate = DateTime.getFirstDayOfWeek(
|
|
500
500
|
visibleMonth.clone().startOf('month')
|
|
501
501
|
)
|
|
502
|
+
|
|
502
503
|
const arr: Moment[] = []
|
|
503
504
|
for (let i = 0; i < Calendar.DAY_COUNT; i++) {
|
|
504
|
-
|
|
505
|
-
|
|
505
|
+
|
|
506
|
+
// This workaround is needed because moment's `.add({days: 1})` function has a bug that happens when the date added lands perfectly onto the DST cutoff,
|
|
507
|
+
// in these cases adding 1 day results in 23 hours added instead,
|
|
508
|
+
// so `moment.tz('2024-09-07T00:00:00', 'America/Santiago').add({days: 1})` results
|
|
509
|
+
// in "Sat Sep 07 2024 23:00:00 GMT-0400" instead of "Sun Sep 08 2024 00:00:00 GMT-0400".
|
|
510
|
+
// which would cause duplicate dates in the calendar.
|
|
511
|
+
// More info on the bug: https://github.com/moment/moment/issues/4743
|
|
512
|
+
// Please note that this causes one hour of time difference in the affected timezones/dates and to
|
|
513
|
+
// fully solve this bug we need to change to something like luxon which handles this properly
|
|
514
|
+
if (currDate.clone().format('HH') === '23') {
|
|
515
|
+
arr.push(currDate.clone().add({hours: 1}))
|
|
516
|
+
} else {
|
|
517
|
+
arr.push(currDate.clone())
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
currDate.add({days: 1})
|
|
506
521
|
}
|
|
507
522
|
return arr.map((date) => {
|
|
508
523
|
const dateStr = date.toISOString()
|