@sparted/shared-library 1.7.72 → 1.7.73

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.
@@ -0,0 +1,6 @@
1
+ import { CampaignDetails, LiveCampaign } from '../types';
2
+ export declare const computeIntenseCalendar: (card: LiveCampaign) => Date[];
3
+ export declare const computeCurrentSession: (card: LiveCampaign) => number;
4
+ export declare const checkTodayPlayable: (card: LiveCampaign) => boolean;
5
+ export declare const findNextAvailableDate: (currentDate: Date, endDate: Date, enabledWeekDays: number[], disabledDates: Date[]) => Date | null;
6
+ export declare const getCalendarSessionDatesFromCampaign: (campaign: CampaignDetails) => Record<number, Date>;
@@ -121,6 +121,3 @@ export type CampaignDetails = {
121
121
  export declare const isCampaignSchedulingRandom: (scheduling: CampaignScheduling) => scheduling is RandomCampaignScheduling;
122
122
  export declare const isCampaignSchedulingManual: (scheduling: CampaignScheduling) => scheduling is ManualCampaignScheduling;
123
123
  export declare const isWikiCard: (item: unknown) => item is WikiCard;
124
- export declare const computeIntenseCalendar: (card: LiveCampaign) => Date[];
125
- export declare const computeCurrentSession: (card: LiveCampaign) => number;
126
- export declare const checkTodayPlayable: (card: LiveCampaign) => boolean;
@@ -4,67 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const isCampaignSchedulingRandom = (scheduling) => scheduling.mode === 'random';
6
6
  const isCampaignSchedulingManual = (scheduling) => scheduling.mode === 'manual';
7
- const isWikiCard = (item) => typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;
8
- const computeIntenseCalendar = (card) => {
9
- const { details } = card;
10
- const startDate = new Date(details.utcStartDate);
11
- const endDate = new Date(details.utcEndDate);
12
- const calculateIntenseCalendarAux = (date, calendar) => {
13
- if (date > endDate) {
14
- return calendar;
15
- }
16
- const jsDay = date.getDay();
17
- const day = jsDay === 0 ? 7 : jsDay;
18
- if (details.enabledWeekDays.includes(day) && !details.disabledDates.includes(date.toISOString().slice(0, 10))) {
19
- calendar.push(new Date(date));
20
- }
21
- date.setDate(date.getDate() + 1);
22
- return calculateIntenseCalendarAux(date, calendar);
23
- };
24
- return calculateIntenseCalendarAux(startDate, []);
25
- };
26
- const computeCurrentSession = (card) => {
27
- const { details, achievement } = card;
28
- if (details.type === 'flexible') {
29
- return Math.min(achievement.lastSessionPlayed + 1, details.sessionCount);
30
- }
31
- const today = new Date();
32
- if (today <= new Date(details.utcStartDate)) {
33
- return 1;
34
- }
35
- if (today >= new Date(details.utcEndDate)) {
36
- return details.sessionCount;
37
- }
38
- const calendar = computeIntenseCalendar(card);
39
- const todayDate = today.toISOString().slice(0, 10);
40
- const currentSession = calendar.findIndex((date) => date.toISOString().slice(0, 10) >= todayDate);
41
- if (currentSession === -1) {
42
- throw new Error('Current session not found');
43
- }
44
- return currentSession + 1;
45
- };
46
- const checkTodayPlayable = (card) => {
47
- const today = new Date();
48
- const { details } = card;
49
- const startDate = new Date(details.utcStartDate);
50
- const endDate = new Date(details.utcEndDate);
51
- if (today < startDate || today > endDate) {
52
- return false;
53
- }
54
- const jsDay = today.getDay();
55
- const day = jsDay === 0 ? 7 : jsDay;
56
- if (!details.enabledWeekDays.includes(day)) {
57
- return false;
58
- }
59
- if (details.disabledDates.includes(today.toISOString().slice(0, 10))) {
60
- return false;
61
- }
62
- return true;
63
- };
7
+ const isWikiCard = (item) => typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;
64
8
 
65
- exports.checkTodayPlayable = checkTodayPlayable;
66
- exports.computeCurrentSession = computeCurrentSession;
67
- exports.computeIntenseCalendar = computeIntenseCalendar;
68
9
  exports.isCampaignSchedulingManual = isCampaignSchedulingManual;
69
10
  exports.isCampaignSchedulingRandom = isCampaignSchedulingRandom;
70
11
  exports.isWikiCard = isWikiCard;
@@ -1 +1 @@
1
- {"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { CampaignStats } from './achievement';\nimport { ActivityStatus } from './activity';\nimport type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { PlayerProfile, PlayerWithParticipation } from './player';\nimport type { Points, Stars } from './score';\n\nexport type WithCampaignContentId<T> = T & { campaignContentId: number };\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n status: ActivityStatus;\n cover: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n contentCount: number;\n isRandom: boolean;\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedIds: number[];\n favorite: boolean;\n};\n\nexport type WikiCard = {\n details: WikiCardDetails;\n playerInteraction: WikiCardPlayerInteraction;\n};\n\nexport type WikiContentCardDetails = {\n id: number;\n campaignContentId: number;\n coverImage: string;\n title: MultilingualLabel;\n explanation?: MultilingualLabel;\n session: number;\n};\n\nexport type WikiContentCard = {\n contentDetails: WikiContentCardDetails;\n points: Points;\n};\n\nexport type LiveCampaignScheduling = {\n type: 'flexible' | 'intense';\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n sessionCount: number;\n};\n\nexport type LiveCampaignDetails = BaseCampaignCardDetails & LiveCampaignScheduling;\n\nexport type LiveCampaignAchievement = {\n lastSessionPlayed: number;\n lastPlayedAt: string;\n stars: Stars;\n points: Points;\n};\n\nexport type SessionInsight = {\n sessionNumber: number;\n gameTypes: GameType[];\n};\n\nexport type LiveCampaign = {\n details: LiveCampaignDetails;\n achievement: LiveCampaignAchievement;\n sessionInsights: SessionInsight[];\n leaderPlayer?: PlayerProfile;\n};\n\nexport type CalendarStatus = 'played' | 'playable' | 'pending' | 'missed';\n\nexport type Calendar = {\n order: number;\n status: CalendarStatus;\n date: Date;\n};\n\nexport type CampaignDetails = {\n id: number;\n coverImage?: Image;\n name: MultilingualLabel;\n mode: 'manual' | 'random';\n launchDate: string;\n endDate: string;\n enabledWeekDays: number[];\n disabledDates: Date[];\n lastNotificationDate: Date;\n nbPlayers: number;\n nbSessions: number;\n nbQuestions: number;\n players: PlayerWithParticipation[];\n stats: CampaignStats;\n};\n\nexport const isCampaignSchedulingRandom = (scheduling: CampaignScheduling): scheduling is RandomCampaignScheduling =>\n scheduling.mode === 'random';\n\nexport const isCampaignSchedulingManual = (scheduling: CampaignScheduling): scheduling is ManualCampaignScheduling =>\n scheduling.mode === 'manual';\n\nexport const isWikiCard = (item: unknown): item is WikiCard =>\n typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;\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.getDay();\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.setDate(date.getDate() + 1);\n\n return calculateIntenseCalendarAux(date, calendar);\n };\n\n return calculateIntenseCalendarAux(startDate, []);\n};\n\nexport const computeCurrentSession = (card: LiveCampaign): number => {\n const { details, achievement } = card;\n\n if (details.type === 'flexible') {\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 currentSession + 1;\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.getDay();\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"],"names":[],"mappings":";;;;AA4IO,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAExB,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAElB,MAAA,UAAU,GAAG,CAAC,IAAa,KACtC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,mBAAmB,IAAI,KAAK;AAEnF,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,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CAAC,EAAE;AAC1C,QAAA,OAAO,KAAK,CAAC;AACd,KAAA;AAED,IAAA,IAAI,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;AACpE,QAAA,OAAO,KAAK,CAAC;AACd,KAAA;AAED,IAAA,OAAO,IAAI,CAAC;AACd;;;;;;;;;"}
1
+ {"version":3,"file":"campaign.js","sources":["../../../src/business/types/campaign.ts"],"sourcesContent":["import type { CampaignStats } from './achievement';\nimport { ActivityStatus } from './activity';\nimport type { Content, GameType } from './content';\nimport type { Image } from './media';\nimport type { MultilingualLabel } from './multilingual';\nimport type { PlayerProfile, PlayerWithParticipation } from './player';\nimport type { Points, Stars } from './score';\n\nexport type WithCampaignContentId<T> = T & { campaignContentId: number };\n\nexport type CampaignInformations = {\n coverImage: Image;\n name: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n lastSave: Date;\n};\n\nexport type BaseCampaignScheduling = {\n type: 'flexible' | 'intense';\n launchDate: string;\n endDate?: string;\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n};\n\nexport type ManualCampaignScheduling = BaseCampaignScheduling & {\n mode: 'manual';\n orderedSessions: Content[][];\n};\n\nexport type RandomCampaignScheduling = BaseCampaignScheduling & {\n mode: 'random';\n nbSessions: number;\n contents: Content[];\n};\n\nexport type CampaignScheduling = ManualCampaignScheduling | RandomCampaignScheduling;\n\nexport type Campaign = {\n id: number;\n informations: CampaignInformations;\n scheduling: CampaignScheduling;\n type: 'campaign';\n};\n\nexport type BaseCampaignCardDetails = {\n id: number;\n status: ActivityStatus;\n cover: string;\n title: MultilingualLabel;\n description: MultilingualLabel;\n disclaimer?: MultilingualLabel;\n utcStartDate: string;\n utcEndDate: string;\n contentCount: number;\n isRandom: boolean;\n};\n\nexport type WikiCardDetails = BaseCampaignCardDetails;\n\nexport type WikiCardPlayerInteraction = {\n contentPlayedIds: number[];\n favorite: boolean;\n};\n\nexport type WikiCard = {\n details: WikiCardDetails;\n playerInteraction: WikiCardPlayerInteraction;\n};\n\nexport type WikiContentCardDetails = {\n id: number;\n campaignContentId: number;\n coverImage: string;\n title: MultilingualLabel;\n explanation?: MultilingualLabel;\n session: number;\n};\n\nexport type WikiContentCard = {\n contentDetails: WikiContentCardDetails;\n points: Points;\n};\n\nexport type LiveCampaignScheduling = {\n type: 'flexible' | 'intense';\n extraDays: number;\n enabledWeekDays: number[];\n disabledDates: string[];\n sessionCount: number;\n};\n\nexport type LiveCampaignDetails = BaseCampaignCardDetails & LiveCampaignScheduling;\n\nexport type LiveCampaignAchievement = {\n lastSessionPlayed: number;\n lastPlayedAt: string;\n stars: Stars;\n points: Points;\n};\n\nexport type SessionInsight = {\n sessionNumber: number;\n gameTypes: GameType[];\n};\n\nexport type LiveCampaign = {\n details: LiveCampaignDetails;\n achievement: LiveCampaignAchievement;\n sessionInsights: SessionInsight[];\n leaderPlayer?: PlayerProfile;\n};\n\nexport type CalendarStatus = 'played' | 'playable' | 'pending' | 'missed';\n\nexport type Calendar = {\n order: number;\n status: CalendarStatus;\n date: Date;\n};\n\nexport type CampaignDetails = {\n id: number;\n coverImage?: Image;\n name: MultilingualLabel;\n mode: 'manual' | 'random';\n launchDate: string;\n endDate: string;\n enabledWeekDays: number[];\n disabledDates: Date[];\n lastNotificationDate: Date;\n nbPlayers: number;\n nbSessions: number;\n nbQuestions: number;\n players: PlayerWithParticipation[];\n stats: CampaignStats;\n};\n\nexport const isCampaignSchedulingRandom = (scheduling: CampaignScheduling): scheduling is RandomCampaignScheduling =>\n scheduling.mode === 'random';\n\nexport const isCampaignSchedulingManual = (scheduling: CampaignScheduling): scheduling is ManualCampaignScheduling =>\n scheduling.mode === 'manual';\n\nexport const isWikiCard = (item: unknown): item is WikiCard =>\n typeof item === 'object' && item !== null && 'details' in item && 'playerInteraction' in item;\n"],"names":[],"mappings":";;;;AA4IO,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAExB,MAAM,0BAA0B,GAAG,CAAC,UAA8B,KACvE,UAAU,CAAC,IAAI,KAAK,SAAS;AAElB,MAAA,UAAU,GAAG,CAAC,IAAa,KACtC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,mBAAmB,IAAI;;;;;;"}
@@ -13,9 +13,6 @@ var score = require('./score.js');
13
13
  exports.ACTIVITY_STATUS = activity.ACTIVITY_STATUS;
14
14
  exports.isActivityBreakingNews = activity.isActivityBreakingNews;
15
15
  exports.isActivityCampaign = activity.isActivityCampaign;
16
- exports.checkTodayPlayable = campaign.checkTodayPlayable;
17
- exports.computeCurrentSession = campaign.computeCurrentSession;
18
- exports.computeIntenseCalendar = campaign.computeIntenseCalendar;
19
16
  exports.isCampaignSchedulingManual = campaign.isCampaignSchedulingManual;
20
17
  exports.isCampaignSchedulingRandom = campaign.isCampaignSchedulingRandom;
21
18
  exports.isWikiCard = campaign.isWikiCard;
@@ -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 addDays: (date: Date, days: number) => Date;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const addDays = (date, days) => {
6
+ const result = new Date(date);
7
+ result.setUTCDate(result.getUTCDate() + days);
8
+ return result;
9
+ };
10
+
11
+ exports.addDays = addDays;
12
+ //# sourceMappingURL=add-days.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-days.js","sources":["../../src/date/add-days.ts"],"sourcesContent":["export const addDays = (date: Date, days: number): Date => {\n const result = new Date(date);\n result.setUTCDate(result.getUTCDate() + days);\n return result;\n};\n"],"names":[],"mappings":";;;;MAAa,OAAO,GAAG,CAAC,IAAU,EAAE,IAAY,KAAU;AACxD,IAAA,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9C,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
@@ -0,0 +1 @@
1
+ export declare const differenceInDays: (start: Date, end: Date) => number;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const differenceInDays = (start, end) => {
6
+ const msPerDay = 24 * 60 * 60 * 1000;
7
+ const utcStart = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());
8
+ const utcEnd = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());
9
+ return Math.floor((utcEnd - utcStart) / msPerDay);
10
+ };
11
+
12
+ exports.differenceInDays = differenceInDays;
13
+ //# sourceMappingURL=difference-in-days.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"difference-in-days.js","sources":["../../src/date/difference-in-days.ts"],"sourcesContent":["export const differenceInDays = (start: Date, end: Date): number => {\n const msPerDay = 24 * 60 * 60 * 1000;\n const utcStart = Date.UTC(start.getFullYear(), start.getMonth(), start.getDate());\n const utcEnd = Date.UTC(end.getFullYear(), end.getMonth(), end.getDate());\n return Math.floor((utcEnd - utcStart) / msPerDay);\n};\n"],"names":[],"mappings":";;;;MAAa,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,WAAW,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAClF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1E,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,QAAQ,IAAI,QAAQ,CAAC,CAAC;AACpD;;;;"}
package/date/index.d.ts CHANGED
@@ -3,3 +3,5 @@ export * from './to-plain-date-string';
3
3
  export * from './get-next-day';
4
4
  export * from './get-remaining-time';
5
5
  export * from './shift-date-by';
6
+ export * from './difference-in-days';
7
+ export * from './add-days';
package/date/index.js CHANGED
@@ -7,6 +7,8 @@ var toPlainDateString = require('./to-plain-date-string.js');
7
7
  var getNextDay = require('./get-next-day.js');
8
8
  var getRemainingTime = require('./get-remaining-time.js');
9
9
  var shiftDateBy = require('./shift-date-by.js');
10
+ var differenceInDays = require('./difference-in-days.js');
11
+ var addDays = require('./add-days.js');
10
12
 
11
13
 
12
14
 
@@ -16,4 +18,6 @@ exports.getNextDay = getNextDay.getNextDay;
16
18
  exports.getRemainingTimeFromMs = getRemainingTime.getRemainingTimeFromMs;
17
19
  exports.getRemainingTimeInMsFromDate = getRemainingTime.getRemainingTimeInMsFromDate;
18
20
  exports.shiftDateBy = shiftDateBy.shiftDateBy;
21
+ exports.differenceInDays = differenceInDays.differenceInDays;
22
+ exports.addDays = addDays.addDays;
19
23
  //# 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":";;;;;;;;;;;;;;;;;;;;;"}
package/index.js CHANGED
@@ -45,6 +45,8 @@ var toPlainDateString = require('./date/to-plain-date-string.js');
45
45
  var getNextDay = require('./date/get-next-day.js');
46
46
  var getRemainingTime = require('./date/get-remaining-time.js');
47
47
  var shiftDateBy = require('./date/shift-date-by.js');
48
+ var differenceInDays = require('./date/difference-in-days.js');
49
+ var addDays = require('./date/add-days.js');
48
50
 
49
51
 
50
52
 
@@ -99,4 +101,6 @@ exports.getNextDay = getNextDay.getNextDay;
99
101
  exports.getRemainingTimeFromMs = getRemainingTime.getRemainingTimeFromMs;
100
102
  exports.getRemainingTimeInMsFromDate = getRemainingTime.getRemainingTimeInMsFromDate;
101
103
  exports.shiftDateBy = shiftDateBy.shiftDateBy;
104
+ exports.differenceInDays = differenceInDays.differenceInDays;
105
+ exports.addDays = addDays.addDays;
102
106
  //# 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.7.72",
3
+ "version": "1.7.73",
4
4
  "repository": "git@github.com:Sparted/shared-library.git",
5
5
  "author": {
6
6
  "name": "Sparted",