orc-shared 5.10.0-dev.20 → 5.10.0-dev.21
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/dist/components/Culture.js +33 -14
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/Provision.js +1 -1
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/sharedMessages.js +180 -0
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/Provision.js +1 -1
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/sharedMessages.js +180 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +45 -0
- package/src/translations/fr-CA.json +45 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
|
@@ -43,13 +43,13 @@ const Provision = ({ store, theme = {}, muiTheme, children }) => {
|
|
|
43
43
|
<MuiThemeProvider theme={muiTheme}>
|
|
44
44
|
<React.Fragment>
|
|
45
45
|
<Head />
|
|
46
|
-
<Culture />
|
|
47
46
|
<GlobalStyle />
|
|
48
47
|
<Authenticate>
|
|
49
48
|
<React.Fragment>
|
|
50
49
|
<Fonts />
|
|
51
50
|
<DevPages>
|
|
52
51
|
<I18n>
|
|
52
|
+
<Culture />
|
|
53
53
|
{React.Children.only(children)}
|
|
54
54
|
<InternetExplorerWarningMessage />
|
|
55
55
|
</I18n>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import sharedMessages from "../sharedMessages";
|
|
4
|
+
|
|
5
|
+
const useDaysAndMonthsLocalization = () => {
|
|
6
|
+
const { formatMessage } = useIntl();
|
|
7
|
+
|
|
8
|
+
return React.useMemo(() => {
|
|
9
|
+
const weekdays = [
|
|
10
|
+
formatMessage(sharedMessages.sunday),
|
|
11
|
+
formatMessage(sharedMessages.monday),
|
|
12
|
+
formatMessage(sharedMessages.tuesday),
|
|
13
|
+
formatMessage(sharedMessages.wednesday),
|
|
14
|
+
formatMessage(sharedMessages.thursday),
|
|
15
|
+
formatMessage(sharedMessages.friday),
|
|
16
|
+
formatMessage(sharedMessages.saturday),
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const weekdaysShort = [
|
|
20
|
+
formatMessage(sharedMessages.sundayShort),
|
|
21
|
+
formatMessage(sharedMessages.mondayShort),
|
|
22
|
+
formatMessage(sharedMessages.tuesdayShort),
|
|
23
|
+
formatMessage(sharedMessages.wednesdayShort),
|
|
24
|
+
formatMessage(sharedMessages.thursdayShort),
|
|
25
|
+
formatMessage(sharedMessages.fridayShort),
|
|
26
|
+
formatMessage(sharedMessages.saturdayShort),
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const weekdaysMin = [
|
|
30
|
+
formatMessage(sharedMessages.sundayMin),
|
|
31
|
+
formatMessage(sharedMessages.mondayMin),
|
|
32
|
+
formatMessage(sharedMessages.tuesdayMin),
|
|
33
|
+
formatMessage(sharedMessages.wednesdayMin),
|
|
34
|
+
formatMessage(sharedMessages.thursdayMin),
|
|
35
|
+
formatMessage(sharedMessages.fridayMin),
|
|
36
|
+
formatMessage(sharedMessages.saturdayMin),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const months = [
|
|
40
|
+
formatMessage(sharedMessages.january),
|
|
41
|
+
formatMessage(sharedMessages.february),
|
|
42
|
+
formatMessage(sharedMessages.march),
|
|
43
|
+
formatMessage(sharedMessages.april),
|
|
44
|
+
formatMessage(sharedMessages.may),
|
|
45
|
+
formatMessage(sharedMessages.june),
|
|
46
|
+
formatMessage(sharedMessages.july),
|
|
47
|
+
formatMessage(sharedMessages.august),
|
|
48
|
+
formatMessage(sharedMessages.september),
|
|
49
|
+
formatMessage(sharedMessages.october),
|
|
50
|
+
formatMessage(sharedMessages.november),
|
|
51
|
+
formatMessage(sharedMessages.december),
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const monthsShort = [
|
|
55
|
+
formatMessage(sharedMessages.januaryShort),
|
|
56
|
+
formatMessage(sharedMessages.februaryShort),
|
|
57
|
+
formatMessage(sharedMessages.marchShort),
|
|
58
|
+
formatMessage(sharedMessages.aprilShort),
|
|
59
|
+
formatMessage(sharedMessages.mayShort),
|
|
60
|
+
formatMessage(sharedMessages.juneShort),
|
|
61
|
+
formatMessage(sharedMessages.julyShort),
|
|
62
|
+
formatMessage(sharedMessages.augustShort),
|
|
63
|
+
formatMessage(sharedMessages.septemberShort),
|
|
64
|
+
formatMessage(sharedMessages.octoberShort),
|
|
65
|
+
formatMessage(sharedMessages.novemberShort),
|
|
66
|
+
formatMessage(sharedMessages.decemberShort),
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
weekdays,
|
|
71
|
+
weekdaysShort,
|
|
72
|
+
weekdaysMin,
|
|
73
|
+
months,
|
|
74
|
+
monthsShort,
|
|
75
|
+
};
|
|
76
|
+
}, [formatMessage]);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default useDaysAndMonthsLocalization;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Immutable from "immutable";
|
|
3
|
+
import { extractMessages, TestWrapper } from "../utils/testUtils";
|
|
4
|
+
import sharedMessages from "../sharedMessages";
|
|
5
|
+
import useDaysAndMonthsLocalization from "./useDaysAndMonthsLocalization";
|
|
6
|
+
|
|
7
|
+
const messages = extractMessages(sharedMessages);
|
|
8
|
+
|
|
9
|
+
describe("useDaysAndMonthsLocalization", () => {
|
|
10
|
+
let store, state;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
state = Immutable.fromJS({});
|
|
14
|
+
|
|
15
|
+
store = {
|
|
16
|
+
subscribe: () => {},
|
|
17
|
+
dispatch: () => {},
|
|
18
|
+
getState: () => state,
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("returns weekdays and months correctly", () => {
|
|
23
|
+
const TestComp = () => {
|
|
24
|
+
const daysAndMonths = useDaysAndMonthsLocalization();
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div>
|
|
28
|
+
{daysAndMonths.weekdays.map(x => (
|
|
29
|
+
<div key={x}>{x}</div>
|
|
30
|
+
))}
|
|
31
|
+
{daysAndMonths.weekdaysShort.map(x => (
|
|
32
|
+
<div key={x}>{x}</div>
|
|
33
|
+
))}
|
|
34
|
+
{daysAndMonths.weekdaysMin.map(x => (
|
|
35
|
+
<div key={x}>{x}</div>
|
|
36
|
+
))}
|
|
37
|
+
{daysAndMonths.months.map(x => (
|
|
38
|
+
<div key={x}>{x}</div>
|
|
39
|
+
))}
|
|
40
|
+
{daysAndMonths.monthsShort.map(x => (
|
|
41
|
+
<div key={x}>{x}</div>
|
|
42
|
+
))}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const component = (
|
|
48
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }}>
|
|
49
|
+
<TestComp />
|
|
50
|
+
</TestWrapper>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const expected = (
|
|
54
|
+
<TestWrapper provider={{ store }} intlProvider={{ messages }}>
|
|
55
|
+
<div>
|
|
56
|
+
<div>Sunday</div>
|
|
57
|
+
<div>Monday</div>
|
|
58
|
+
<div>Tuesday</div>
|
|
59
|
+
<div>Wednesday</div>
|
|
60
|
+
<div>Thursday</div>
|
|
61
|
+
<div>Friday</div>
|
|
62
|
+
<div>Saturday</div>
|
|
63
|
+
<div>Sun</div>
|
|
64
|
+
<div>Mon</div>
|
|
65
|
+
<div>Tue</div>
|
|
66
|
+
<div>Wed</div>
|
|
67
|
+
<div>Thu</div>
|
|
68
|
+
<div>Fri</div>
|
|
69
|
+
<div>Sat</div>
|
|
70
|
+
<div>Su</div>
|
|
71
|
+
<div>Mo</div>
|
|
72
|
+
<div>Tu</div>
|
|
73
|
+
<div>We</div>
|
|
74
|
+
<div>Th</div>
|
|
75
|
+
<div>Fr</div>
|
|
76
|
+
<div>Sa</div>
|
|
77
|
+
<div>January</div>
|
|
78
|
+
<div>February</div>
|
|
79
|
+
<div>March</div>
|
|
80
|
+
<div>April</div>
|
|
81
|
+
<div>May</div>
|
|
82
|
+
<div>June</div>
|
|
83
|
+
<div>July</div>
|
|
84
|
+
<div>August</div>
|
|
85
|
+
<div>September</div>
|
|
86
|
+
<div>October</div>
|
|
87
|
+
<div>November</div>
|
|
88
|
+
<div>December</div>
|
|
89
|
+
<div>Jan</div>
|
|
90
|
+
<div>Feb</div>
|
|
91
|
+
<div>Mar</div>
|
|
92
|
+
<div>Apr</div>
|
|
93
|
+
<div>May</div>
|
|
94
|
+
<div>Jun</div>
|
|
95
|
+
<div>Jul</div>
|
|
96
|
+
<div>Aug</div>
|
|
97
|
+
<div>Sep</div>
|
|
98
|
+
<div>Oct</div>
|
|
99
|
+
<div>Nov</div>
|
|
100
|
+
<div>Dec</div>
|
|
101
|
+
</div>
|
|
102
|
+
</TestWrapper>
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
expect(component, "when mounted", "to satisfy", expected);
|
|
106
|
+
});
|
|
107
|
+
});
|
package/src/sharedMessages.js
CHANGED
|
@@ -303,6 +303,186 @@ const sharedMessages = defineMessages({
|
|
|
303
303
|
id: "orc-shared.search",
|
|
304
304
|
defaultMessage: "Search",
|
|
305
305
|
},
|
|
306
|
+
sundayMin: {
|
|
307
|
+
id: "orc-shared.sundayMin",
|
|
308
|
+
defaultMessage: "Su",
|
|
309
|
+
},
|
|
310
|
+
mondayMin: {
|
|
311
|
+
id: "orc-shared.mondayMin",
|
|
312
|
+
defaultMessage: "Mo",
|
|
313
|
+
},
|
|
314
|
+
tuesdayMin: {
|
|
315
|
+
id: "orc-shared.tuesdayMin",
|
|
316
|
+
defaultMessage: "Tu",
|
|
317
|
+
},
|
|
318
|
+
wednesdayMin: {
|
|
319
|
+
id: "orc-shared.wednesdayMin",
|
|
320
|
+
defaultMessage: "We",
|
|
321
|
+
},
|
|
322
|
+
thursdayMin: {
|
|
323
|
+
id: "orc-shared.thursdayMin",
|
|
324
|
+
defaultMessage: "Th",
|
|
325
|
+
},
|
|
326
|
+
fridayMin: {
|
|
327
|
+
id: "orc-shared.fridayMin",
|
|
328
|
+
defaultMessage: "Fr",
|
|
329
|
+
},
|
|
330
|
+
saturdayMin: {
|
|
331
|
+
id: "orc-shared.saturdayMin",
|
|
332
|
+
defaultMessage: "Sa",
|
|
333
|
+
},
|
|
334
|
+
sundayShort: {
|
|
335
|
+
id: "orc-shared.sundayShort",
|
|
336
|
+
defaultMessage: "Sun",
|
|
337
|
+
},
|
|
338
|
+
mondayShort: {
|
|
339
|
+
id: "orc-shared.mondayShort",
|
|
340
|
+
defaultMessage: "Mon",
|
|
341
|
+
},
|
|
342
|
+
tuesdayShort: {
|
|
343
|
+
id: "orc-shared.tuesdayShort",
|
|
344
|
+
defaultMessage: "Tue",
|
|
345
|
+
},
|
|
346
|
+
wednesdayShort: {
|
|
347
|
+
id: "orc-shared.wednesdayShort",
|
|
348
|
+
defaultMessage: "Wed",
|
|
349
|
+
},
|
|
350
|
+
thursdayShort: {
|
|
351
|
+
id: "orc-shared.thursdayShort",
|
|
352
|
+
defaultMessage: "Thu",
|
|
353
|
+
},
|
|
354
|
+
fridayShort: {
|
|
355
|
+
id: "orc-shared.fridayShort",
|
|
356
|
+
defaultMessage: "Fri",
|
|
357
|
+
},
|
|
358
|
+
saturdayShort: {
|
|
359
|
+
id: "orc-shared.saturdayShort",
|
|
360
|
+
defaultMessage: "Sat",
|
|
361
|
+
},
|
|
362
|
+
sunday: {
|
|
363
|
+
id: "orc-shared.sunday",
|
|
364
|
+
defaultMessage: "Sunday",
|
|
365
|
+
},
|
|
366
|
+
monday: {
|
|
367
|
+
id: "orc-shared.monday",
|
|
368
|
+
defaultMessage: "Monday",
|
|
369
|
+
},
|
|
370
|
+
tuesday: {
|
|
371
|
+
id: "orc-shared.tuesday",
|
|
372
|
+
defaultMessage: "Tuesday",
|
|
373
|
+
},
|
|
374
|
+
wednesday: {
|
|
375
|
+
id: "orc-shared.wednesday",
|
|
376
|
+
defaultMessage: "Wednesday",
|
|
377
|
+
},
|
|
378
|
+
thursday: {
|
|
379
|
+
id: "orc-shared.thursday",
|
|
380
|
+
defaultMessage: "Thursday",
|
|
381
|
+
},
|
|
382
|
+
friday: {
|
|
383
|
+
id: "orc-shared.friday",
|
|
384
|
+
defaultMessage: "Friday",
|
|
385
|
+
},
|
|
386
|
+
saturday: {
|
|
387
|
+
id: "orc-shared.saturday",
|
|
388
|
+
defaultMessage: "Saturday",
|
|
389
|
+
},
|
|
390
|
+
januaryShort: {
|
|
391
|
+
id: "orc-shared.januaryShort",
|
|
392
|
+
defaultMessage: "Jan",
|
|
393
|
+
},
|
|
394
|
+
februaryShort: {
|
|
395
|
+
id: "orc-shared.februaryShort",
|
|
396
|
+
defaultMessage: "Feb",
|
|
397
|
+
},
|
|
398
|
+
marchShort: {
|
|
399
|
+
id: "orc-shared.marchShort",
|
|
400
|
+
defaultMessage: "Mar",
|
|
401
|
+
},
|
|
402
|
+
aprilShort: {
|
|
403
|
+
id: "orc-shared.aprilShort",
|
|
404
|
+
defaultMessage: "Apr",
|
|
405
|
+
},
|
|
406
|
+
mayShort: {
|
|
407
|
+
id: "orc-shared.mayShort",
|
|
408
|
+
defaultMessage: "May",
|
|
409
|
+
},
|
|
410
|
+
juneShort: {
|
|
411
|
+
id: "orc-shared.juneShort",
|
|
412
|
+
defaultMessage: "Jun",
|
|
413
|
+
},
|
|
414
|
+
julyShort: {
|
|
415
|
+
id: "orc-shared.julyShort",
|
|
416
|
+
defaultMessage: "Jul",
|
|
417
|
+
},
|
|
418
|
+
augustShort: {
|
|
419
|
+
id: "orc-shared.augustShort",
|
|
420
|
+
defaultMessage: "Aug",
|
|
421
|
+
},
|
|
422
|
+
septemberShort: {
|
|
423
|
+
id: "orc-shared.septemberShort",
|
|
424
|
+
defaultMessage: "Sep",
|
|
425
|
+
},
|
|
426
|
+
octoberShort: {
|
|
427
|
+
id: "orc-shared.octoberShort",
|
|
428
|
+
defaultMessage: "Oct",
|
|
429
|
+
},
|
|
430
|
+
novemberShort: {
|
|
431
|
+
id: "orc-shared.novemberShort",
|
|
432
|
+
defaultMessage: "Nov",
|
|
433
|
+
},
|
|
434
|
+
decemberShort: {
|
|
435
|
+
id: "orc-shared.decemberShort",
|
|
436
|
+
defaultMessage: "Dec",
|
|
437
|
+
},
|
|
438
|
+
january: {
|
|
439
|
+
id: "orc-shared.january",
|
|
440
|
+
defaultMessage: "January",
|
|
441
|
+
},
|
|
442
|
+
february: {
|
|
443
|
+
id: "orc-shared.february",
|
|
444
|
+
defaultMessage: "February",
|
|
445
|
+
},
|
|
446
|
+
march: {
|
|
447
|
+
id: "orc-shared.march",
|
|
448
|
+
defaultMessage: "March",
|
|
449
|
+
},
|
|
450
|
+
april: {
|
|
451
|
+
id: "orc-shared.april",
|
|
452
|
+
defaultMessage: "April",
|
|
453
|
+
},
|
|
454
|
+
may: {
|
|
455
|
+
id: "orc-shared.may",
|
|
456
|
+
defaultMessage: "May",
|
|
457
|
+
},
|
|
458
|
+
june: {
|
|
459
|
+
id: "orc-shared.june",
|
|
460
|
+
defaultMessage: "June",
|
|
461
|
+
},
|
|
462
|
+
july: {
|
|
463
|
+
id: "orc-shared.july",
|
|
464
|
+
defaultMessage: "July",
|
|
465
|
+
},
|
|
466
|
+
august: {
|
|
467
|
+
id: "orc-shared.august",
|
|
468
|
+
defaultMessage: "August",
|
|
469
|
+
},
|
|
470
|
+
september: {
|
|
471
|
+
id: "orc-shared.september",
|
|
472
|
+
defaultMessage: "September",
|
|
473
|
+
},
|
|
474
|
+
october: {
|
|
475
|
+
id: "orc-shared.october",
|
|
476
|
+
defaultMessage: "October",
|
|
477
|
+
},
|
|
478
|
+
november: {
|
|
479
|
+
id: "orc-shared.november",
|
|
480
|
+
defaultMessage: "November",
|
|
481
|
+
},
|
|
482
|
+
december: {
|
|
483
|
+
id: "orc-shared.december",
|
|
484
|
+
defaultMessage: "December",
|
|
485
|
+
},
|
|
306
486
|
});
|
|
307
487
|
|
|
308
488
|
export default sharedMessages;
|