@sparted/shared-library 1.9.6 → 1.10.0
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/business/campaign/live-campaign.js +4 -4
- package/business/campaign/live-campaign.js.map +1 -1
- package/business/types/content.d.ts +23 -0
- package/date/difference-in-days.js +3 -2
- package/date/difference-in-days.js.map +1 -1
- package/date/get-next-day.js +4 -5
- package/date/get-next-day.js.map +1 -1
- package/date/index.d.ts +1 -0
- package/date/index.js +2 -0
- package/date/index.js.map +1 -1
- package/date/to-local-date-string.d.ts +1 -0
- package/date/to-local-date-string.js +10 -0
- package/date/to-local-date-string.js.map +1 -0
- package/date/to-utc-date-string.js +3 -3
- package/date/to-utc-date-string.js.map +1 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +3 -2
|
@@ -13,12 +13,12 @@ const computeIntenseCalendar = (card) => {
|
|
|
13
13
|
if (date > endDate) {
|
|
14
14
|
return calendar;
|
|
15
15
|
}
|
|
16
|
-
const jsDay = date.
|
|
16
|
+
const jsDay = date.getUTCDay();
|
|
17
17
|
const day = jsDay === 0 ? 7 : jsDay;
|
|
18
18
|
if (details.enabledWeekDays.includes(day) && !details.disabledDates.includes(date.toISOString().slice(0, 10))) {
|
|
19
19
|
calendar.push(new Date(date));
|
|
20
20
|
}
|
|
21
|
-
date.
|
|
21
|
+
date.setUTCDate(date.getUTCDate() + 1);
|
|
22
22
|
return calculateIntenseCalendarAux(date, calendar);
|
|
23
23
|
};
|
|
24
24
|
return calculateIntenseCalendarAux(startDate, []);
|
|
@@ -51,7 +51,7 @@ const checkTodayPlayable = (card) => {
|
|
|
51
51
|
if (today < startDate || today > endDate) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
|
-
const jsDay = today.
|
|
54
|
+
const jsDay = today.getUTCDay();
|
|
55
55
|
const day = jsDay === 0 ? 7 : jsDay;
|
|
56
56
|
if (!details.enabledWeekDays.includes(day)) {
|
|
57
57
|
return false;
|
|
@@ -64,7 +64,7 @@ const checkTodayPlayable = (card) => {
|
|
|
64
64
|
const findNextAvailableDate = (currentDate, enabledWeekDays, disabledDates) => {
|
|
65
65
|
if (enabledWeekDays.length === 0)
|
|
66
66
|
return null;
|
|
67
|
-
const dayofDate = currentDate.
|
|
67
|
+
const dayofDate = currentDate.getUTCDay();
|
|
68
68
|
const isEnabledDay = enabledWeekDays.includes(dayofDate === 0 ? 7 : dayofDate);
|
|
69
69
|
const isDisabledDate = disabledDates.some((d) => isSameDate.isSameDate(d, currentDate));
|
|
70
70
|
if (isEnabledDay && !isDisabledDate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-campaign.js","sources":["../../../src/business/campaign/live-campaign.ts"],"sourcesContent":["import { addDays, isSameDate } from '../../date';\nimport { CampaignDetails, LiveCampaign } from '../types';\n\nexport const computeIntenseCalendar = (card: LiveCampaign): Date[] => {\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n const calculateIntenseCalendarAux = (date: Date, calendar: Date[]): Date[] => {\n if (date > endDate) {\n return calendar;\n }\n\n const jsDay = date.
|
|
1
|
+
{"version":3,"file":"live-campaign.js","sources":["../../../src/business/campaign/live-campaign.ts"],"sourcesContent":["import { addDays, isSameDate } from '../../date';\nimport { CampaignDetails, LiveCampaign } from '../types';\n\nexport const computeIntenseCalendar = (card: LiveCampaign): Date[] => {\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n const calculateIntenseCalendarAux = (date: Date, calendar: Date[]): Date[] => {\n if (date > endDate) {\n return calendar;\n }\n\n const jsDay = date.getUTCDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (details.enabledWeekDays.includes(day) && !details.disabledDates.includes(date.toISOString().slice(0, 10))) {\n calendar.push(new Date(date));\n }\n\n date.setUTCDate(date.getUTCDate() + 1);\n\n return calculateIntenseCalendarAux(date, calendar);\n };\n\n return calculateIntenseCalendarAux(startDate, []);\n};\n\nexport const computeCurrentSession = (card: LiveCampaign, forceComputeCalendar?: boolean): number => {\n const { details, achievement } = card;\n\n if (details.type === 'flexible' && !forceComputeCalendar) {\n return Math.min(achievement.lastSessionPlayed + 1, details.sessionCount);\n }\n\n const today = new Date();\n\n if (today <= new Date(details.utcStartDate)) {\n return 1;\n }\n\n if (today >= new Date(details.utcEndDate)) {\n return details.sessionCount;\n }\n\n const calendar = computeIntenseCalendar(card);\n\n const todayDate = today.toISOString().slice(0, 10);\n const currentSession = calendar.findIndex((date) => date.toISOString().slice(0, 10) >= todayDate);\n\n if (currentSession === -1) {\n throw new Error('Current session not found');\n }\n\n return Math.min(currentSession + 1, details.sessionCount);\n};\n\nexport const checkTodayPlayable = (card: LiveCampaign): boolean => {\n const today = new Date();\n\n const { details } = card;\n\n const startDate = new Date(details.utcStartDate);\n const endDate = new Date(details.utcEndDate);\n\n if (today < startDate || today > endDate) {\n return false;\n }\n\n const jsDay = today.getUTCDay();\n const day = jsDay === 0 ? 7 : jsDay;\n\n if (!details.enabledWeekDays.includes(day)) {\n return false;\n }\n\n if (details.disabledDates.includes(today.toISOString().slice(0, 10))) {\n return false;\n }\n\n return true;\n};\n\nexport const findNextAvailableDate = (\n currentDate: Date,\n enabledWeekDays: number[],\n disabledDates: Date[],\n): Date | null => {\n if (enabledWeekDays.length === 0) return null;\n const dayofDate = currentDate.getUTCDay();\n const isEnabledDay = enabledWeekDays.includes(dayofDate === 0 ? 7 : dayofDate);\n const isDisabledDate = disabledDates.some((d) => isSameDate(d, currentDate));\n\n if (isEnabledDay && !isDisabledDate) {\n return currentDate;\n }\n\n return findNextAvailableDate(addDays(currentDate, 1), enabledWeekDays, disabledDates);\n};\n\ntype GetCalendarSessionDatesFromCampaignProps = Pick<\n CampaignDetails,\n 'launchDate' | 'enabledWeekDays' | 'disabledDates' | 'nbSessions'\n> & {\n extraDays?: number;\n};\n\nexport const getCalendarSessionDatesFromCampaign = ({\n launchDate,\n enabledWeekDays,\n disabledDates,\n nbSessions,\n extraDays = 0,\n}: GetCalendarSessionDatesFromCampaignProps): Record<number, Date> => {\n const sessionCount = nbSessions + extraDays;\n\n const calendarDatesBySession = Array.from({ length: sessionCount }).reduce((acc: Record<number, Date>, _, index) => {\n const session = index + 1;\n const lastDate = session > 1 ? addDays(new Date(acc[session - 1]), 1) : new Date(launchDate);\n\n const nextSessionDate = findNextAvailableDate(lastDate, enabledWeekDays, disabledDates);\n\n if (!nextSessionDate) return acc;\n\n return {\n ...acc,\n [session]: nextSessionDate,\n };\n }, {});\n\n return calendarDatesBySession;\n};\n"],"names":["isSameDate","addDays"],"mappings":";;;;;;;AAGa,MAAA,sBAAsB,GAAG,CAAC,IAAkB,KAAY;AACnE,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C,IAAA,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAE,QAAgB,KAAY;QAC3E,IAAI,IAAI,GAAG,OAAO,EAAE;AAClB,YAAA,OAAO,QAAQ,CAAC;AACjB,SAAA;AAED,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;AAC/B,QAAA,MAAM,GAAG,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEpC,QAAA,IAAI,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;YAC7G,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/B,SAAA;QAED,I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CACN,EAAA,EAAA,CAAC,OAAO,GAAG,eAAe,EAC1B,CAAA,CAAA;KACH,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,OAAO,sBAAsB,CAAC;AAChC;;;;;;;;"}
|
|
@@ -183,6 +183,7 @@ export declare const isPartialGameMultipleChoiceQuestion: (game: DeepPartial<Gam
|
|
|
183
183
|
"id-ID"?: string | undefined;
|
|
184
184
|
"lv-LV"?: string | undefined;
|
|
185
185
|
"th-TH"?: string | undefined;
|
|
186
|
+
"vi-VN"?: string | undefined;
|
|
186
187
|
} | undefined;
|
|
187
188
|
choices?: ({
|
|
188
189
|
text?: {
|
|
@@ -221,6 +222,7 @@ export declare const isPartialGameMultipleChoiceQuestion: (game: DeepPartial<Gam
|
|
|
221
222
|
"id-ID"?: string | undefined;
|
|
222
223
|
"lv-LV"?: string | undefined;
|
|
223
224
|
"th-TH"?: string | undefined;
|
|
225
|
+
"vi-VN"?: string | undefined;
|
|
224
226
|
} | undefined;
|
|
225
227
|
correct?: boolean | undefined;
|
|
226
228
|
} | undefined)[] | undefined;
|
|
@@ -274,6 +276,7 @@ export declare const isPartialGameMultipleChoiceQuestion: (game: DeepPartial<Gam
|
|
|
274
276
|
"id-ID"?: string | undefined;
|
|
275
277
|
"lv-LV"?: string | undefined;
|
|
276
278
|
"th-TH"?: string | undefined;
|
|
279
|
+
"vi-VN"?: string | undefined;
|
|
277
280
|
} | undefined;
|
|
278
281
|
};
|
|
279
282
|
export declare const isPartialGameErrorText: (game: DeepPartial<Game>) => game is {
|
|
@@ -329,6 +332,7 @@ export declare const isPartialGameErrorText: (game: DeepPartial<Game>) => game i
|
|
|
329
332
|
"id-ID"?: string | undefined;
|
|
330
333
|
"lv-LV"?: string | undefined;
|
|
331
334
|
"th-TH"?: string | undefined;
|
|
335
|
+
"vi-VN"?: string | undefined;
|
|
332
336
|
} | undefined;
|
|
333
337
|
correctText?: {
|
|
334
338
|
id?: number | undefined;
|
|
@@ -366,6 +370,7 @@ export declare const isPartialGameErrorText: (game: DeepPartial<Game>) => game i
|
|
|
366
370
|
"id-ID"?: string | undefined;
|
|
367
371
|
"lv-LV"?: string | undefined;
|
|
368
372
|
"th-TH"?: string | undefined;
|
|
373
|
+
"vi-VN"?: string | undefined;
|
|
369
374
|
} | undefined;
|
|
370
375
|
explanationMedia?: {
|
|
371
376
|
image?: {
|
|
@@ -417,6 +422,7 @@ export declare const isPartialGameErrorText: (game: DeepPartial<Game>) => game i
|
|
|
417
422
|
"id-ID"?: string | undefined;
|
|
418
423
|
"lv-LV"?: string | undefined;
|
|
419
424
|
"th-TH"?: string | undefined;
|
|
425
|
+
"vi-VN"?: string | undefined;
|
|
420
426
|
} | undefined;
|
|
421
427
|
};
|
|
422
428
|
export declare const isPartialGameOpenQuestion: (game: DeepPartial<Game>) => game is {
|
|
@@ -472,6 +478,7 @@ export declare const isPartialGameOpenQuestion: (game: DeepPartial<Game>) => gam
|
|
|
472
478
|
"id-ID"?: string | undefined;
|
|
473
479
|
"lv-LV"?: string | undefined;
|
|
474
480
|
"th-TH"?: string | undefined;
|
|
481
|
+
"vi-VN"?: string | undefined;
|
|
475
482
|
} | undefined;
|
|
476
483
|
answer?: {
|
|
477
484
|
id?: number | undefined;
|
|
@@ -509,6 +516,7 @@ export declare const isPartialGameOpenQuestion: (game: DeepPartial<Game>) => gam
|
|
|
509
516
|
"id-ID"?: string | undefined;
|
|
510
517
|
"lv-LV"?: string | undefined;
|
|
511
518
|
"th-TH"?: string | undefined;
|
|
519
|
+
"vi-VN"?: string | undefined;
|
|
512
520
|
} | undefined;
|
|
513
521
|
levenshteinDistance?: number | undefined;
|
|
514
522
|
explanationMedia?: {
|
|
@@ -561,6 +569,7 @@ export declare const isPartialGameOpenQuestion: (game: DeepPartial<Game>) => gam
|
|
|
561
569
|
"id-ID"?: string | undefined;
|
|
562
570
|
"lv-LV"?: string | undefined;
|
|
563
571
|
"th-TH"?: string | undefined;
|
|
572
|
+
"vi-VN"?: string | undefined;
|
|
564
573
|
} | undefined;
|
|
565
574
|
};
|
|
566
575
|
export declare const isPartialGameNoInteraction: (game: DeepPartial<Game>) => game is {
|
|
@@ -616,6 +625,7 @@ export declare const isPartialGameNoInteraction: (game: DeepPartial<Game>) => ga
|
|
|
616
625
|
"id-ID"?: string | undefined;
|
|
617
626
|
"lv-LV"?: string | undefined;
|
|
618
627
|
"th-TH"?: string | undefined;
|
|
628
|
+
"vi-VN"?: string | undefined;
|
|
619
629
|
} | undefined;
|
|
620
630
|
text?: {
|
|
621
631
|
id?: number | undefined;
|
|
@@ -653,6 +663,7 @@ export declare const isPartialGameNoInteraction: (game: DeepPartial<Game>) => ga
|
|
|
653
663
|
"id-ID"?: string | undefined;
|
|
654
664
|
"lv-LV"?: string | undefined;
|
|
655
665
|
"th-TH"?: string | undefined;
|
|
666
|
+
"vi-VN"?: string | undefined;
|
|
656
667
|
} | undefined;
|
|
657
668
|
secondMedia?: {
|
|
658
669
|
image?: {
|
|
@@ -720,6 +731,7 @@ export declare const isPartialGamePictureSpot: (game: DeepPartial<Game>) => game
|
|
|
720
731
|
"id-ID"?: string | undefined;
|
|
721
732
|
"lv-LV"?: string | undefined;
|
|
722
733
|
"th-TH"?: string | undefined;
|
|
734
|
+
"vi-VN"?: string | undefined;
|
|
723
735
|
} | undefined;
|
|
724
736
|
description?: {
|
|
725
737
|
id?: number | undefined;
|
|
@@ -757,6 +769,7 @@ export declare const isPartialGamePictureSpot: (game: DeepPartial<Game>) => game
|
|
|
757
769
|
"id-ID"?: string | undefined;
|
|
758
770
|
"lv-LV"?: string | undefined;
|
|
759
771
|
"th-TH"?: string | undefined;
|
|
772
|
+
"vi-VN"?: string | undefined;
|
|
760
773
|
} | undefined;
|
|
761
774
|
} | undefined)[] | undefined;
|
|
762
775
|
explanation?: {
|
|
@@ -795,6 +808,7 @@ export declare const isPartialGamePictureSpot: (game: DeepPartial<Game>) => game
|
|
|
795
808
|
"id-ID"?: string | undefined;
|
|
796
809
|
"lv-LV"?: string | undefined;
|
|
797
810
|
"th-TH"?: string | undefined;
|
|
811
|
+
"vi-VN"?: string | undefined;
|
|
798
812
|
} | undefined;
|
|
799
813
|
};
|
|
800
814
|
export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => game is {
|
|
@@ -836,6 +850,7 @@ export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => ga
|
|
|
836
850
|
"id-ID"?: string | undefined;
|
|
837
851
|
"lv-LV"?: string | undefined;
|
|
838
852
|
"th-TH"?: string | undefined;
|
|
853
|
+
"vi-VN"?: string | undefined;
|
|
839
854
|
} | undefined;
|
|
840
855
|
topLabel?: {
|
|
841
856
|
id?: number | undefined;
|
|
@@ -873,6 +888,7 @@ export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => ga
|
|
|
873
888
|
"id-ID"?: string | undefined;
|
|
874
889
|
"lv-LV"?: string | undefined;
|
|
875
890
|
"th-TH"?: string | undefined;
|
|
891
|
+
"vi-VN"?: string | undefined;
|
|
876
892
|
} | undefined;
|
|
877
893
|
cards?: ({
|
|
878
894
|
id?: number | undefined;
|
|
@@ -910,6 +926,7 @@ export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => ga
|
|
|
910
926
|
"id-ID"?: string | undefined;
|
|
911
927
|
"lv-LV"?: string | undefined;
|
|
912
928
|
"th-TH"?: string | undefined;
|
|
929
|
+
"vi-VN"?: string | undefined;
|
|
913
930
|
} | undefined)[] | undefined;
|
|
914
931
|
bottomLabel?: {
|
|
915
932
|
id?: number | undefined;
|
|
@@ -947,6 +964,7 @@ export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => ga
|
|
|
947
964
|
"id-ID"?: string | undefined;
|
|
948
965
|
"lv-LV"?: string | undefined;
|
|
949
966
|
"th-TH"?: string | undefined;
|
|
967
|
+
"vi-VN"?: string | undefined;
|
|
950
968
|
} | undefined;
|
|
951
969
|
explanation?: {
|
|
952
970
|
id?: number | undefined;
|
|
@@ -984,6 +1002,7 @@ export declare const isPartialGameOrderingCards: (game: DeepPartial<Game>) => ga
|
|
|
984
1002
|
"id-ID"?: string | undefined;
|
|
985
1003
|
"lv-LV"?: string | undefined;
|
|
986
1004
|
"th-TH"?: string | undefined;
|
|
1005
|
+
"vi-VN"?: string | undefined;
|
|
987
1006
|
} | undefined;
|
|
988
1007
|
};
|
|
989
1008
|
export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => game is {
|
|
@@ -1025,6 +1044,7 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
|
|
|
1025
1044
|
"id-ID"?: string | undefined;
|
|
1026
1045
|
"lv-LV"?: string | undefined;
|
|
1027
1046
|
"th-TH"?: string | undefined;
|
|
1047
|
+
"vi-VN"?: string | undefined;
|
|
1028
1048
|
} | undefined;
|
|
1029
1049
|
zones?: ({
|
|
1030
1050
|
position?: SwipingCardPosition | undefined;
|
|
@@ -1064,6 +1084,7 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
|
|
|
1064
1084
|
"id-ID"?: string | undefined;
|
|
1065
1085
|
"lv-LV"?: string | undefined;
|
|
1066
1086
|
"th-TH"?: string | undefined;
|
|
1087
|
+
"vi-VN"?: string | undefined;
|
|
1067
1088
|
} | undefined;
|
|
1068
1089
|
} | undefined)[] | undefined;
|
|
1069
1090
|
cards?: ({
|
|
@@ -1110,6 +1131,7 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
|
|
|
1110
1131
|
"id-ID"?: string | undefined;
|
|
1111
1132
|
"lv-LV"?: string | undefined;
|
|
1112
1133
|
"th-TH"?: string | undefined;
|
|
1134
|
+
"vi-VN"?: string | undefined;
|
|
1113
1135
|
} | undefined;
|
|
1114
1136
|
answer?: SwipingCardPosition | undefined;
|
|
1115
1137
|
} | undefined)[] | undefined;
|
|
@@ -1149,6 +1171,7 @@ export declare const isPartialGameSwipingCards: (game: DeepPartial<Game>) => gam
|
|
|
1149
1171
|
"id-ID"?: string | undefined;
|
|
1150
1172
|
"lv-LV"?: string | undefined;
|
|
1151
1173
|
"th-TH"?: string | undefined;
|
|
1174
|
+
"vi-VN"?: string | undefined;
|
|
1152
1175
|
} | undefined;
|
|
1153
1176
|
};
|
|
1154
1177
|
export declare const extractGameExplanation: (game?: Game) => MultilingualLabel | undefined;
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
// Number of UTC calendar days from start to end, so it agrees with toUTCDateString and isSameDate.
|
|
5
6
|
const differenceInDays = (start, end) => {
|
|
6
7
|
const msPerDay = 24 * 60 * 60 * 1000;
|
|
7
|
-
const utcStart = Date.UTC(start.
|
|
8
|
-
const utcEnd = Date.UTC(end.
|
|
8
|
+
const utcStart = Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate());
|
|
9
|
+
const utcEnd = Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate());
|
|
9
10
|
return Math.floor((utcEnd - utcStart) / msPerDay);
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"difference-in-days.js","sources":["../../src/date/difference-in-days.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"difference-in-days.js","sources":["../../src/date/difference-in-days.ts"],"sourcesContent":["// Number of UTC calendar days from start to end, so it agrees with toUTCDateString and isSameDate.\nexport const differenceInDays = (start: Date, end: Date): number => {\n const msPerDay = 24 * 60 * 60 * 1000;\n const utcStart = Date.UTC(start.getUTCFullYear(), start.getUTCMonth(), start.getUTCDate());\n const utcEnd = Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate());\n return Math.floor((utcEnd - utcStart) / msPerDay);\n};\n"],"names":[],"mappings":";;;;AAAA;MACa,gBAAgB,GAAG,CAAC,KAAW,EAAE,GAAS,KAAY;IACjE,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3F,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;AACnF,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,QAAQ,IAAI,QAAQ,CAAC,CAAC;AACpD;;;;"}
|
package/date/get-next-day.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
5
|
+
var addDays = require('./add-days.js');
|
|
6
|
+
|
|
7
|
+
// Next day on the UTC calendar, so it agrees with toUTCDateString and isSameDate.
|
|
8
|
+
const getNextDay = (date) => addDays.addDays(date, 1);
|
|
10
9
|
|
|
11
10
|
exports.getNextDay = getNextDay;
|
|
12
11
|
//# sourceMappingURL=get-next-day.js.map
|
package/date/get-next-day.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-next-day.js","sources":["../../src/date/get-next-day.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"get-next-day.js","sources":["../../src/date/get-next-day.ts"],"sourcesContent":["import { addDays } from './add-days';\n\n// Next day on the UTC calendar, so it agrees with toUTCDateString and isSameDate.\nexport const getNextDay = (date: Date): Date => addDays(date, 1);\n"],"names":["addDays"],"mappings":";;;;;;AAEA;AACO,MAAM,UAAU,GAAG,CAAC,IAAU,KAAWA,eAAO,CAAC,IAAI,EAAE,CAAC;;;;"}
|
package/date/index.d.ts
CHANGED
package/date/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var differenceInDays = require('./difference-in-days.js');
|
|
|
11
11
|
var addDays = require('./add-days.js');
|
|
12
12
|
var getStartOfDay = require('./get-start-of-day.js');
|
|
13
13
|
var toUtcDateString = require('./to-utc-date-string.js');
|
|
14
|
+
var toLocalDateString = require('./to-local-date-string.js');
|
|
14
15
|
var getIsoDayNumber = require('./get-iso-day-number.js');
|
|
15
16
|
|
|
16
17
|
|
|
@@ -26,5 +27,6 @@ exports.addDays = addDays.addDays;
|
|
|
26
27
|
exports.startOfDay = getStartOfDay.startOfDay;
|
|
27
28
|
exports.startOfDayLocal = getStartOfDay.startOfDayLocal;
|
|
28
29
|
exports.toUTCDateString = toUtcDateString.toUTCDateString;
|
|
30
|
+
exports.toLocalDateString = toLocalDateString.toLocalDateString;
|
|
29
31
|
exports.getIsoDayNumber = getIsoDayNumber.getIsoDayNumber;
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
package/date/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toLocalDateString: (date: Date) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const toLocalDateString = (date) => {
|
|
6
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())).toISOString().split('T')[0];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.toLocalDateString = toLocalDateString;
|
|
10
|
+
//# sourceMappingURL=to-local-date-string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-local-date-string.js","sources":["../../src/date/to-local-date-string.ts"],"sourcesContent":["export const toLocalDateString = (date: Date) => {\n return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())).toISOString().split('T')[0];\n};\n"],"names":[],"mappings":";;;;AAAa,MAAA,iBAAiB,GAAG,CAAC,IAAU,KAAI;AAC9C,IAAA,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7G;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var toPlainDateString = require('./to-plain-date-string.js');
|
|
6
|
+
|
|
7
|
+
const toUTCDateString = (date) => toPlainDateString.toPlainDateString(date);
|
|
8
8
|
|
|
9
9
|
exports.toUTCDateString = toUTCDateString;
|
|
10
10
|
//# sourceMappingURL=to-utc-date-string.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-utc-date-string.js","sources":["../../src/date/to-utc-date-string.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"to-utc-date-string.js","sources":["../../src/date/to-utc-date-string.ts"],"sourcesContent":["import { toPlainDateString } from './to-plain-date-string';\n\nexport const toUTCDateString = (date: Date) => toPlainDateString(date);\n"],"names":["toPlainDateString"],"mappings":";;;;;;AAEO,MAAM,eAAe,GAAG,CAAC,IAAU,KAAKA,mCAAiB,CAAC,IAAI;;;;"}
|
package/index.js
CHANGED
|
@@ -57,6 +57,7 @@ var differenceInDays = require('./date/difference-in-days.js');
|
|
|
57
57
|
var addDays = require('./date/add-days.js');
|
|
58
58
|
var getStartOfDay = require('./date/get-start-of-day.js');
|
|
59
59
|
var toUtcDateString = require('./date/to-utc-date-string.js');
|
|
60
|
+
var toLocalDateString = require('./date/to-local-date-string.js');
|
|
60
61
|
var getIsoDayNumber = require('./date/get-iso-day-number.js');
|
|
61
62
|
|
|
62
63
|
|
|
@@ -155,5 +156,6 @@ exports.addDays = addDays.addDays;
|
|
|
155
156
|
exports.startOfDay = getStartOfDay.startOfDay;
|
|
156
157
|
exports.startOfDayLocal = getStartOfDay.startOfDayLocal;
|
|
157
158
|
exports.toUTCDateString = toUtcDateString.toUTCDateString;
|
|
159
|
+
exports.toLocalDateString = toLocalDateString.toLocalDateString;
|
|
158
160
|
exports.getIsoDayNumber = getIsoDayNumber.getIsoDayNumber;
|
|
159
161
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparted/shared-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"repository": "git@github.com:Sparted/shared-library.git",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Sparted",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"**/**"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "jest",
|
|
18
|
+
"test": "jest && yarn test:timezones",
|
|
19
|
+
"test:timezones": "node scripts/test-timezones.js",
|
|
19
20
|
"lint": "eslint .",
|
|
20
21
|
"clean": "rm -rf ./dist",
|
|
21
22
|
"build": "yarn clean && rollup --config rollup.config.ts --configPlugin typescript2 && cp package.json ./dist/package.json",
|