@chayns-components/date 5.0.0-beta.433
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/LICENSE +21 -0
- package/README.md +34 -0
- package/lib/components/calendar/Calendar.d.ts +36 -0
- package/lib/components/calendar/Calendar.js +141 -0
- package/lib/components/calendar/Calendar.js.map +1 -0
- package/lib/components/calendar/Calendar.styles.d.ts +4 -0
- package/lib/components/calendar/Calendar.styles.js +20 -0
- package/lib/components/calendar/Calendar.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.d.ts +17 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.js +137 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.js.map +1 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +271 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.styles.js +24 -0
- package/lib/components/calendar/month-wrapper/MonthWrapper.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/Month.d.ts +14 -0
- package/lib/components/calendar/month-wrapper/month/Month.js +43 -0
- package/lib/components/calendar/month-wrapper/month/Month.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/Month.styles.d.ts +4 -0
- package/lib/components/calendar/month-wrapper/month/Month.styles.js +23 -0
- package/lib/components/calendar/month-wrapper/month/Month.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.d.ts +12 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +60 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.d.ts +2 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js +17 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.d.ts +12 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +66 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.d.ts +15 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js +75 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/Day.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.d.ts +6 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js +20 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.d.ts +7 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js +21 -0
- package/lib/components/calendar/month-wrapper/month/day-wrapper/day/category/Category.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +7 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +45 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.d.ts +2 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js +16 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.styles.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.d.ts +6 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js +18 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.js.map +1 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.d.ts +4 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js +19 -0
- package/lib/components/calendar/month-wrapper/month/weekday-wrapper/weekday/Weekday.styles.js.map +1 -0
- package/lib/components/date-info/DateInfo.d.ts +37 -0
- package/lib/components/date-info/DateInfo.js +110 -0
- package/lib/components/date-info/DateInfo.js.map +1 -0
- package/lib/components/opening-times/OpeningTimes.d.ts +27 -0
- package/lib/components/opening-times/OpeningTimes.js +135 -0
- package/lib/components/opening-times/OpeningTimes.js.map +1 -0
- package/lib/components/opening-times/OpeningTimes.styles.d.ts +8 -0
- package/lib/components/opening-times/OpeningTimes.styles.js +19 -0
- package/lib/components/opening-times/OpeningTimes.styles.js.map +1 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.d.ts +12 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.js +94 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.js.map +1 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +2 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js +13 -0
- package/lib/components/opening-times/opening-inputs/OpeningInputs.styles.js.map +1 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.d.ts +14 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js +100 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.js.map +1 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +274 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js +46 -0
- package/lib/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.js.map +1 -0
- package/lib/constants/dateInfo.d.ts +22 -0
- package/lib/constants/dateInfo.js +629 -0
- package/lib/constants/dateInfo.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/types/calendar.d.ts +32 -0
- package/lib/types/calendar.js +22 -0
- package/lib/types/calendar.js.map +1 -0
- package/lib/types/openingTimes.d.ts +28 -0
- package/lib/types/openingTimes.js +13 -0
- package/lib/types/openingTimes.js.map +1 -0
- package/lib/utils/calendar.d.ts +15 -0
- package/lib/utils/calendar.js +58 -0
- package/lib/utils/calendar.js.map +1 -0
- package/lib/utils/dateInfo.d.ts +55 -0
- package/lib/utils/dateInfo.js +364 -0
- package/lib/utils/dateInfo.js.map +1 -0
- package/package.json +69 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Calendar", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Calendar.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "DateInfo", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _DateInfo.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "OpeningTimes", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _OpeningTimes.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _Calendar = _interopRequireDefault(require("./components/calendar/Calendar"));
|
|
25
|
+
var _DateInfo = _interopRequireDefault(require("./components/date-info/DateInfo"));
|
|
26
|
+
var _OpeningTimes = _interopRequireDefault(require("./components/opening-times/OpeningTimes"));
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Calendar","_interopRequireDefault","require","_DateInfo","_OpeningTimes","obj","__esModule","default"],"sources":["../src/index.ts"],"sourcesContent":["export { default as Calendar } from './components/calendar/Calendar';\nexport type { Categories, HighlightedDates, HighlightedDateStyles } from './types/calendar';\nexport { default as DateInfo } from './components/date-info/DateInfo';\nexport { default as OpeningTimes } from './components/opening-times/OpeningTimes';\nexport type { OpeningTime, Time, Weekday } from './types/openingTimes';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAkF,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
export interface HighlightedDates {
|
|
3
|
+
dates: Date[];
|
|
4
|
+
style: HighlightedDateStyles;
|
|
5
|
+
}
|
|
6
|
+
export interface HighlightedDateStyles {
|
|
7
|
+
backgroundColor: CSSProperties['backgroundColor'];
|
|
8
|
+
textColor: CSSProperties['color'];
|
|
9
|
+
}
|
|
10
|
+
export interface Categories {
|
|
11
|
+
id: string;
|
|
12
|
+
dates: Date[];
|
|
13
|
+
color: CSSProperties['color'];
|
|
14
|
+
}
|
|
15
|
+
export interface IMonth {
|
|
16
|
+
month: EMonth;
|
|
17
|
+
year: string;
|
|
18
|
+
}
|
|
19
|
+
export declare enum EMonth {
|
|
20
|
+
January = 1,
|
|
21
|
+
February = 2,
|
|
22
|
+
March = 3,
|
|
23
|
+
April = 4,
|
|
24
|
+
May = 5,
|
|
25
|
+
June = 6,
|
|
26
|
+
July = 7,
|
|
27
|
+
August = 8,
|
|
28
|
+
September = 9,
|
|
29
|
+
October = 10,
|
|
30
|
+
November = 11,
|
|
31
|
+
December = 12
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.EMonth = void 0;
|
|
7
|
+
let EMonth = exports.EMonth = /*#__PURE__*/function (EMonth) {
|
|
8
|
+
EMonth[EMonth["January"] = 1] = "January";
|
|
9
|
+
EMonth[EMonth["February"] = 2] = "February";
|
|
10
|
+
EMonth[EMonth["March"] = 3] = "March";
|
|
11
|
+
EMonth[EMonth["April"] = 4] = "April";
|
|
12
|
+
EMonth[EMonth["May"] = 5] = "May";
|
|
13
|
+
EMonth[EMonth["June"] = 6] = "June";
|
|
14
|
+
EMonth[EMonth["July"] = 7] = "July";
|
|
15
|
+
EMonth[EMonth["August"] = 8] = "August";
|
|
16
|
+
EMonth[EMonth["September"] = 9] = "September";
|
|
17
|
+
EMonth[EMonth["October"] = 10] = "October";
|
|
18
|
+
EMonth[EMonth["November"] = 11] = "November";
|
|
19
|
+
EMonth[EMonth["December"] = 12] = "December";
|
|
20
|
+
return EMonth;
|
|
21
|
+
}({});
|
|
22
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","names":["EMonth","exports"],"sources":["../../src/types/calendar.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport interface HighlightedDates {\n dates: Date[];\n style: HighlightedDateStyles;\n}\n\nexport interface HighlightedDateStyles {\n backgroundColor: CSSProperties['backgroundColor'];\n textColor: CSSProperties['color'];\n}\n\nexport interface Categories {\n id: string;\n dates: Date[];\n color: CSSProperties['color'];\n}\n\nexport interface IMonth {\n month: EMonth;\n year: string;\n}\n\nexport enum EMonth {\n January = 1,\n February,\n March,\n April,\n May,\n June,\n July,\n August,\n September,\n October,\n November,\n December,\n}\n"],"mappings":";;;;;;IAuBYA,MAAM,GAAAC,OAAA,CAAAD,MAAA,0BAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAANA,MAAM,CAANA,MAAM;EAAA,OAANA,MAAM;AAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface Weekday {
|
|
2
|
+
name: string;
|
|
3
|
+
id: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Time {
|
|
6
|
+
id: string;
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
}
|
|
10
|
+
export interface OpeningTime {
|
|
11
|
+
weekdayId: Weekday['id'];
|
|
12
|
+
id: string;
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
times: Time[];
|
|
15
|
+
}
|
|
16
|
+
export interface OnTimeAdd {
|
|
17
|
+
dayId: OpeningTime['id'];
|
|
18
|
+
time: Time;
|
|
19
|
+
}
|
|
20
|
+
export interface OnChange {
|
|
21
|
+
enabledDays?: OpeningTime['id'][];
|
|
22
|
+
time?: Time;
|
|
23
|
+
}
|
|
24
|
+
export declare enum OpeningTimesButtonType {
|
|
25
|
+
NONE = 0,
|
|
26
|
+
ADD = 1,
|
|
27
|
+
REMOVE = 2
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OpeningTimesButtonType = void 0;
|
|
7
|
+
let OpeningTimesButtonType = exports.OpeningTimesButtonType = /*#__PURE__*/function (OpeningTimesButtonType) {
|
|
8
|
+
OpeningTimesButtonType[OpeningTimesButtonType["NONE"] = 0] = "NONE";
|
|
9
|
+
OpeningTimesButtonType[OpeningTimesButtonType["ADD"] = 1] = "ADD";
|
|
10
|
+
OpeningTimesButtonType[OpeningTimesButtonType["REMOVE"] = 2] = "REMOVE";
|
|
11
|
+
return OpeningTimesButtonType;
|
|
12
|
+
}({});
|
|
13
|
+
//# sourceMappingURL=openingTimes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openingTimes.js","names":["OpeningTimesButtonType","exports"],"sources":["../../src/types/openingTimes.ts"],"sourcesContent":["export interface Weekday {\n name: string;\n id: number;\n}\n\nexport interface Time {\n id: string;\n start: string;\n end: string;\n}\n\nexport interface OpeningTime {\n weekdayId: Weekday['id'];\n id: string;\n isDisabled?: boolean;\n times: Time[];\n}\n\nexport interface OnTimeAdd {\n dayId: OpeningTime['id'];\n time: Time;\n}\n\nexport interface OnChange {\n enabledDays?: OpeningTime['id'][];\n time?: Time;\n}\n\nexport enum OpeningTimesButtonType {\n NONE,\n ADD,\n REMOVE,\n}\n"],"mappings":";;;;;;IA4BYA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAtBA,sBAAsB,CAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EMonth, IMonth } from '../types/calendar';
|
|
2
|
+
export declare const getMonthAndYear: (date: Date) => IMonth;
|
|
3
|
+
interface FormatMonthOptions {
|
|
4
|
+
month: EMonth;
|
|
5
|
+
locale: Locale;
|
|
6
|
+
}
|
|
7
|
+
interface IsDateInRange {
|
|
8
|
+
startDate: Date;
|
|
9
|
+
endDate: Date;
|
|
10
|
+
currentDate: Date;
|
|
11
|
+
}
|
|
12
|
+
export declare const isDateInRange: ({ startDate, endDate, currentDate }: IsDateInRange) => Date;
|
|
13
|
+
export declare const getNewDate: (index: number, currentDate: Date) => Date;
|
|
14
|
+
export declare const formatMonth: ({ month, locale }: FormatMonthOptions) => string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isDateInRange = exports.getNewDate = exports.getMonthAndYear = exports.formatMonth = void 0;
|
|
7
|
+
var _dateFns = require("date-fns");
|
|
8
|
+
const getMonthAndYear = date => {
|
|
9
|
+
const month = date.getMonth() + 1;
|
|
10
|
+
const year = String(date.getFullYear());
|
|
11
|
+
return {
|
|
12
|
+
month,
|
|
13
|
+
year
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.getMonthAndYear = getMonthAndYear;
|
|
17
|
+
const isDateInRange = _ref => {
|
|
18
|
+
let {
|
|
19
|
+
startDate,
|
|
20
|
+
endDate,
|
|
21
|
+
currentDate
|
|
22
|
+
} = _ref;
|
|
23
|
+
const monthStartOfCurrentDate = (0, _dateFns.startOfMonth)(currentDate);
|
|
24
|
+
const monthStartOfEndDate = (0, _dateFns.startOfMonth)(endDate);
|
|
25
|
+
const monthStartOfStartDate = (0, _dateFns.startOfMonth)(startDate);
|
|
26
|
+
switch (true) {
|
|
27
|
+
case (0, _dateFns.isAfter)(monthStartOfCurrentDate, monthStartOfEndDate):
|
|
28
|
+
return monthStartOfEndDate;
|
|
29
|
+
case (0, _dateFns.isBefore)(monthStartOfCurrentDate, monthStartOfStartDate):
|
|
30
|
+
return monthStartOfStartDate;
|
|
31
|
+
default:
|
|
32
|
+
return monthStartOfCurrentDate;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.isDateInRange = isDateInRange;
|
|
36
|
+
const getNewDate = (index, currentDate) => {
|
|
37
|
+
const newDate = new Date(currentDate);
|
|
38
|
+
newDate.setMonth(currentDate.getMonth() + index);
|
|
39
|
+
if (currentDate.getMonth() === 11 && newDate.getMonth() === 0) {
|
|
40
|
+
newDate.setFullYear(currentDate.getFullYear() + 1);
|
|
41
|
+
}
|
|
42
|
+
if (currentDate.getMonth() === 0 && newDate.getMonth() === 11) {
|
|
43
|
+
newDate.setFullYear(currentDate.getFullYear() - 1);
|
|
44
|
+
}
|
|
45
|
+
return newDate;
|
|
46
|
+
};
|
|
47
|
+
exports.getNewDate = getNewDate;
|
|
48
|
+
const formatMonth = _ref2 => {
|
|
49
|
+
let {
|
|
50
|
+
month,
|
|
51
|
+
locale
|
|
52
|
+
} = _ref2;
|
|
53
|
+
return (0, _dateFns.format)(new Date(2022, month - 1, 1), 'MMMM', {
|
|
54
|
+
locale
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
exports.formatMonth = formatMonth;
|
|
58
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.js","names":["_dateFns","require","getMonthAndYear","date","month","getMonth","year","String","getFullYear","exports","isDateInRange","_ref","startDate","endDate","currentDate","monthStartOfCurrentDate","startOfMonth","monthStartOfEndDate","monthStartOfStartDate","isAfter","isBefore","getNewDate","index","newDate","Date","setMonth","setFullYear","formatMonth","_ref2","locale","format"],"sources":["../../src/utils/calendar.ts"],"sourcesContent":["import { format, isAfter, isBefore, startOfMonth } from 'date-fns';\nimport type { EMonth, IMonth } from '../types/calendar';\n\nexport const getMonthAndYear = (date: Date): IMonth => {\n const month = date.getMonth() + 1;\n\n const year = String(date.getFullYear());\n\n return {\n month,\n year,\n };\n};\n\ninterface FormatMonthOptions {\n month: EMonth;\n locale: Locale;\n}\n\ninterface IsDateInRange {\n startDate: Date;\n endDate: Date;\n currentDate: Date;\n}\n\nexport const isDateInRange = ({ startDate, endDate, currentDate }: IsDateInRange): Date => {\n const monthStartOfCurrentDate = startOfMonth(currentDate);\n const monthStartOfEndDate = startOfMonth(endDate);\n const monthStartOfStartDate = startOfMonth(startDate);\n\n switch (true) {\n case isAfter(monthStartOfCurrentDate, monthStartOfEndDate):\n return monthStartOfEndDate;\n case isBefore(monthStartOfCurrentDate, monthStartOfStartDate):\n return monthStartOfStartDate;\n default:\n return monthStartOfCurrentDate;\n }\n};\n\nexport const getNewDate = (index: number, currentDate: Date) => {\n const newDate = new Date(currentDate);\n newDate.setMonth(currentDate.getMonth() + index);\n\n if (currentDate.getMonth() === 11 && newDate.getMonth() === 0) {\n newDate.setFullYear(currentDate.getFullYear() + 1);\n }\n\n if (currentDate.getMonth() === 0 && newDate.getMonth() === 11) {\n newDate.setFullYear(currentDate.getFullYear() - 1);\n }\n\n return newDate;\n};\n\nexport const formatMonth = ({ month, locale }: FormatMonthOptions) =>\n format(new Date(2022, month - 1, 1), 'MMMM', { locale });\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAGO,MAAMC,eAAe,GAAIC,IAAU,IAAa;EACnD,MAAMC,KAAK,GAAGD,IAAI,CAACE,QAAQ,CAAC,CAAC,GAAG,CAAC;EAEjC,MAAMC,IAAI,GAAGC,MAAM,CAACJ,IAAI,CAACK,WAAW,CAAC,CAAC,CAAC;EAEvC,OAAO;IACHJ,KAAK;IACLE;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAP,eAAA,GAAAA,eAAA;AAaK,MAAMQ,aAAa,GAAGC,IAAA,IAA8D;EAAA,IAA7D;IAAEC,SAAS;IAAEC,OAAO;IAAEC;EAA2B,CAAC,GAAAH,IAAA;EAC5E,MAAMI,uBAAuB,GAAG,IAAAC,qBAAY,EAACF,WAAW,CAAC;EACzD,MAAMG,mBAAmB,GAAG,IAAAD,qBAAY,EAACH,OAAO,CAAC;EACjD,MAAMK,qBAAqB,GAAG,IAAAF,qBAAY,EAACJ,SAAS,CAAC;EAErD,QAAQ,IAAI;IACR,KAAK,IAAAO,gBAAO,EAACJ,uBAAuB,EAAEE,mBAAmB,CAAC;MACtD,OAAOA,mBAAmB;IAC9B,KAAK,IAAAG,iBAAQ,EAACL,uBAAuB,EAAEG,qBAAqB,CAAC;MACzD,OAAOA,qBAAqB;IAChC;MACI,OAAOH,uBAAuB;EACtC;AACJ,CAAC;AAACN,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAEK,MAAMW,UAAU,GAAGA,CAACC,KAAa,EAAER,WAAiB,KAAK;EAC5D,MAAMS,OAAO,GAAG,IAAIC,IAAI,CAACV,WAAW,CAAC;EACrCS,OAAO,CAACE,QAAQ,CAACX,WAAW,CAACT,QAAQ,CAAC,CAAC,GAAGiB,KAAK,CAAC;EAEhD,IAAIR,WAAW,CAACT,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAIkB,OAAO,CAAClB,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE;IAC3DkB,OAAO,CAACG,WAAW,CAACZ,WAAW,CAACN,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;EACtD;EAEA,IAAIM,WAAW,CAACT,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAIkB,OAAO,CAAClB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3DkB,OAAO,CAACG,WAAW,CAACZ,WAAW,CAACN,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;EACtD;EAEA,OAAOe,OAAO;AAClB,CAAC;AAACd,OAAA,CAAAY,UAAA,GAAAA,UAAA;AAEK,MAAMM,WAAW,GAAGC,KAAA;EAAA,IAAC;IAAExB,KAAK;IAAEyB;EAA2B,CAAC,GAAAD,KAAA;EAAA,OAC7D,IAAAE,eAAM,EAAC,IAAIN,IAAI,CAAC,IAAI,EAAEpB,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE;IAAEyB;EAAO,CAAC,CAAC;AAAA;AAACpB,OAAA,CAAAkB,WAAA,GAAAA,WAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type TimeTypeStringsRecord } from '../constants/dateInfo';
|
|
2
|
+
export declare const getLanguage: () => Locale;
|
|
3
|
+
interface GetTimeStringProps {
|
|
4
|
+
language?: string;
|
|
5
|
+
isMorning?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const getTimeString: ({ language, isMorning }: GetTimeStringProps) => "" | "uur" | "heures" | "AM" | "PM" | "Uhr" | "h";
|
|
8
|
+
interface GetFormattedYearOptions {
|
|
9
|
+
date: Date;
|
|
10
|
+
shouldShowThisYear?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const getYearFormat: ({ date, shouldShowThisYear }: GetFormattedYearOptions) => "" | " yyyy";
|
|
13
|
+
interface GetFormattedMonthOptions {
|
|
14
|
+
shouldUseShortText?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const getMonthFormat: ({ shouldUseShortText }: GetFormattedMonthOptions) => "LLL." | "LLLL";
|
|
17
|
+
interface GetFormattedDayOfWeekOptions {
|
|
18
|
+
shouldShowDayOfWeek?: boolean;
|
|
19
|
+
shouldShowRelativeDayOfWeek?: boolean;
|
|
20
|
+
shouldUseShortText?: boolean;
|
|
21
|
+
date: Date;
|
|
22
|
+
language?: Locale;
|
|
23
|
+
}
|
|
24
|
+
export declare const getFormattedDayOfWeek: ({ shouldShowRelativeDayOfWeek, shouldShowDayOfWeek, shouldUseShortText, date, language, }: GetFormattedDayOfWeekOptions) => string;
|
|
25
|
+
interface GetFormattedTimeOptions {
|
|
26
|
+
shouldShowTime?: boolean;
|
|
27
|
+
date: Date;
|
|
28
|
+
language: Locale;
|
|
29
|
+
}
|
|
30
|
+
export declare const getFormattedTime: ({ shouldShowTime, date, language }: GetFormattedTimeOptions) => string;
|
|
31
|
+
export declare const isMorning: (date: Date) => boolean;
|
|
32
|
+
export interface Time {
|
|
33
|
+
value: number;
|
|
34
|
+
type: TimeType;
|
|
35
|
+
isPast: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare enum TimeType {
|
|
38
|
+
Seconds = 0,
|
|
39
|
+
Minutes = 1,
|
|
40
|
+
Hours = 2,
|
|
41
|
+
Days = 3,
|
|
42
|
+
Weeks = 4,
|
|
43
|
+
Months = 5,
|
|
44
|
+
Years = 6
|
|
45
|
+
}
|
|
46
|
+
export declare const getTimeTypeStrings: (language: string) => TimeTypeStringsRecord | undefined;
|
|
47
|
+
interface GetTimeTillNowOptions {
|
|
48
|
+
date: Date;
|
|
49
|
+
currentDate: Date;
|
|
50
|
+
language: Locale;
|
|
51
|
+
}
|
|
52
|
+
export declare const getTimeTillNow: ({ date, currentDate, language }: GetTimeTillNowOptions) => string;
|
|
53
|
+
export declare const getFormattedPastTimeString: (time: Time, language: Locale) => string;
|
|
54
|
+
export declare const getFormattedFutureTimeString: (time: Time, language: Locale) => string;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isMorning = exports.getYearFormat = exports.getTimeTypeStrings = exports.getTimeTillNow = exports.getTimeString = exports.getMonthFormat = exports.getLanguage = exports.getFormattedTime = exports.getFormattedPastTimeString = exports.getFormattedFutureTimeString = exports.getFormattedDayOfWeek = exports.TimeType = void 0;
|
|
7
|
+
var _dateFns = require("date-fns");
|
|
8
|
+
var _dateInfo = require("../constants/dateInfo");
|
|
9
|
+
var _chaynsApi = require("chayns-api");
|
|
10
|
+
var _locale = require("date-fns/locale");
|
|
11
|
+
const getLanguage = () => {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
13
|
+
switch ((0, _chaynsApi.getLanguage)().translation || (0, _chaynsApi.getLanguage)().site) {
|
|
14
|
+
case 'en':
|
|
15
|
+
return _locale.enGB;
|
|
16
|
+
case 'nl':
|
|
17
|
+
return _locale.nl;
|
|
18
|
+
case 'fr':
|
|
19
|
+
return _locale.fr;
|
|
20
|
+
case 'it':
|
|
21
|
+
return _locale.it;
|
|
22
|
+
case 'pl':
|
|
23
|
+
return _locale.pl;
|
|
24
|
+
case 'pt':
|
|
25
|
+
return _locale.pt;
|
|
26
|
+
case 'es':
|
|
27
|
+
return _locale.es;
|
|
28
|
+
case 'tr':
|
|
29
|
+
return _locale.tr;
|
|
30
|
+
case 'uk':
|
|
31
|
+
return _locale.uk;
|
|
32
|
+
default:
|
|
33
|
+
return _locale.de;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.getLanguage = getLanguage;
|
|
37
|
+
const getTimeString = _ref => {
|
|
38
|
+
let {
|
|
39
|
+
language,
|
|
40
|
+
isMorning
|
|
41
|
+
} = _ref;
|
|
42
|
+
switch (language) {
|
|
43
|
+
case 'en-GB':
|
|
44
|
+
case 'pt':
|
|
45
|
+
return isMorning ? 'AM' : 'PM';
|
|
46
|
+
case 'nl':
|
|
47
|
+
return 'uur';
|
|
48
|
+
case 'fr':
|
|
49
|
+
return 'heures';
|
|
50
|
+
case 'de':
|
|
51
|
+
return 'Uhr';
|
|
52
|
+
case 'es':
|
|
53
|
+
return 'h';
|
|
54
|
+
default:
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.getTimeString = getTimeString;
|
|
59
|
+
const getYearFormat = _ref2 => {
|
|
60
|
+
let {
|
|
61
|
+
date,
|
|
62
|
+
shouldShowThisYear
|
|
63
|
+
} = _ref2;
|
|
64
|
+
if (shouldShowThisYear) {
|
|
65
|
+
return ' yyyy';
|
|
66
|
+
}
|
|
67
|
+
return (0, _dateFns.isThisYear)(date) ? '' : ' yyyy';
|
|
68
|
+
};
|
|
69
|
+
exports.getYearFormat = getYearFormat;
|
|
70
|
+
const getMonthFormat = _ref3 => {
|
|
71
|
+
let {
|
|
72
|
+
shouldUseShortText
|
|
73
|
+
} = _ref3;
|
|
74
|
+
if (shouldUseShortText) {
|
|
75
|
+
return 'LLL.';
|
|
76
|
+
}
|
|
77
|
+
return 'LLLL';
|
|
78
|
+
};
|
|
79
|
+
exports.getMonthFormat = getMonthFormat;
|
|
80
|
+
const getFormattedDayOfWeek = _ref4 => {
|
|
81
|
+
let {
|
|
82
|
+
shouldShowRelativeDayOfWeek,
|
|
83
|
+
shouldShowDayOfWeek,
|
|
84
|
+
shouldUseShortText,
|
|
85
|
+
date,
|
|
86
|
+
language
|
|
87
|
+
} = _ref4;
|
|
88
|
+
if (!shouldShowDayOfWeek && !shouldShowRelativeDayOfWeek) {
|
|
89
|
+
return '';
|
|
90
|
+
}
|
|
91
|
+
if (shouldShowRelativeDayOfWeek) {
|
|
92
|
+
if ((0, _dateFns.isToday)(date)) {
|
|
93
|
+
switch (language?.code) {
|
|
94
|
+
case 'en-GB':
|
|
95
|
+
return 'Today, ';
|
|
96
|
+
case 'nl':
|
|
97
|
+
return 'Vandaag, ';
|
|
98
|
+
case 'fr':
|
|
99
|
+
return "Aujourd'hui, ";
|
|
100
|
+
case 'it':
|
|
101
|
+
return 'Oggi, ';
|
|
102
|
+
case 'pl':
|
|
103
|
+
return 'Dzisiaj, ';
|
|
104
|
+
case 'pt':
|
|
105
|
+
return 'Hoje, ';
|
|
106
|
+
case 'es':
|
|
107
|
+
return 'Hoy, ';
|
|
108
|
+
case 'tr':
|
|
109
|
+
return 'Bugün, ';
|
|
110
|
+
case 'uk':
|
|
111
|
+
return 'Сьогодні, ';
|
|
112
|
+
default:
|
|
113
|
+
return 'Heute, ';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if ((0, _dateFns.isTomorrow)(date)) {
|
|
117
|
+
switch (language?.code) {
|
|
118
|
+
case 'en-GB':
|
|
119
|
+
return 'Tomorrow, ';
|
|
120
|
+
case 'nl':
|
|
121
|
+
return 'Morgen, ';
|
|
122
|
+
case 'fr':
|
|
123
|
+
return 'Demain, ';
|
|
124
|
+
case 'it':
|
|
125
|
+
return 'Domani, ';
|
|
126
|
+
case 'pl':
|
|
127
|
+
return 'Jutro, ';
|
|
128
|
+
case 'pt':
|
|
129
|
+
return 'Amanhã, ';
|
|
130
|
+
case 'es':
|
|
131
|
+
return 'Mañana, ';
|
|
132
|
+
case 'tr':
|
|
133
|
+
return 'Yarın, ';
|
|
134
|
+
case 'uk':
|
|
135
|
+
return 'Завтра, ';
|
|
136
|
+
default:
|
|
137
|
+
return 'Morgen, ';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if ((0, _dateFns.isYesterday)(date)) {
|
|
141
|
+
switch (language?.code) {
|
|
142
|
+
case 'en-GB':
|
|
143
|
+
return 'Yesterday, ';
|
|
144
|
+
case 'nl':
|
|
145
|
+
return 'Gisteren, ';
|
|
146
|
+
case 'fr':
|
|
147
|
+
return 'Hier, ';
|
|
148
|
+
case 'it':
|
|
149
|
+
return 'Ieri, ';
|
|
150
|
+
case 'pl':
|
|
151
|
+
return 'Wczoraj, ';
|
|
152
|
+
case 'pt':
|
|
153
|
+
return 'Ontem, ';
|
|
154
|
+
case 'es':
|
|
155
|
+
return 'Ayer, ';
|
|
156
|
+
case 'tr':
|
|
157
|
+
return 'Dün, ';
|
|
158
|
+
case 'uk':
|
|
159
|
+
return 'Вчора, ';
|
|
160
|
+
default:
|
|
161
|
+
return 'Gestern, ';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (shouldUseShortText) {
|
|
166
|
+
return (0, _dateFns.format)(date, 'E., ', {
|
|
167
|
+
locale: language
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return (0, _dateFns.format)(date, 'EEEE, ', {
|
|
171
|
+
locale: language
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
exports.getFormattedDayOfWeek = getFormattedDayOfWeek;
|
|
175
|
+
const getFormattedTime = _ref5 => {
|
|
176
|
+
let {
|
|
177
|
+
shouldShowTime,
|
|
178
|
+
date,
|
|
179
|
+
language
|
|
180
|
+
} = _ref5;
|
|
181
|
+
if (!shouldShowTime) {
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
let timeFormat = 'HH:mm';
|
|
185
|
+
if (language.code === 'en-GB' || language.code === 'pt') {
|
|
186
|
+
timeFormat = 'KK:mm';
|
|
187
|
+
}
|
|
188
|
+
return `, ${(0, _dateFns.format)(date, timeFormat)} ${getTimeString({
|
|
189
|
+
language: language.code,
|
|
190
|
+
isMorning: isMorning(date)
|
|
191
|
+
})}`;
|
|
192
|
+
};
|
|
193
|
+
exports.getFormattedTime = getFormattedTime;
|
|
194
|
+
const isMorning = date => {
|
|
195
|
+
const hours = date.getHours();
|
|
196
|
+
return hours >= 0 && hours < 12;
|
|
197
|
+
};
|
|
198
|
+
exports.isMorning = isMorning;
|
|
199
|
+
let TimeType = exports.TimeType = /*#__PURE__*/function (TimeType) {
|
|
200
|
+
TimeType[TimeType["Seconds"] = 0] = "Seconds";
|
|
201
|
+
TimeType[TimeType["Minutes"] = 1] = "Minutes";
|
|
202
|
+
TimeType[TimeType["Hours"] = 2] = "Hours";
|
|
203
|
+
TimeType[TimeType["Days"] = 3] = "Days";
|
|
204
|
+
TimeType[TimeType["Weeks"] = 4] = "Weeks";
|
|
205
|
+
TimeType[TimeType["Months"] = 5] = "Months";
|
|
206
|
+
TimeType[TimeType["Years"] = 6] = "Years";
|
|
207
|
+
return TimeType;
|
|
208
|
+
}({});
|
|
209
|
+
const getTimeTypeStrings = language => _dateInfo.TIME_TYPE_STRINGS[language === 'en-GB' ? 'en' : language];
|
|
210
|
+
exports.getTimeTypeStrings = getTimeTypeStrings;
|
|
211
|
+
const getTimeTillNow = _ref6 => {
|
|
212
|
+
let {
|
|
213
|
+
date,
|
|
214
|
+
currentDate,
|
|
215
|
+
language
|
|
216
|
+
} = _ref6;
|
|
217
|
+
const time = {
|
|
218
|
+
value: 0,
|
|
219
|
+
type: TimeType.Years,
|
|
220
|
+
isPast: false
|
|
221
|
+
};
|
|
222
|
+
if ((0, _dateFns.isPast)(date)) {
|
|
223
|
+
const elapsedMilliseconds = currentDate.getTime() - date.getTime();
|
|
224
|
+
switch (true) {
|
|
225
|
+
case elapsedMilliseconds < 60000:
|
|
226
|
+
time.value = Math.floor(elapsedMilliseconds / 1000);
|
|
227
|
+
time.type = TimeType.Seconds;
|
|
228
|
+
break;
|
|
229
|
+
case elapsedMilliseconds < 3600000:
|
|
230
|
+
time.value = Math.floor(elapsedMilliseconds / 60000);
|
|
231
|
+
time.type = TimeType.Minutes;
|
|
232
|
+
break;
|
|
233
|
+
case elapsedMilliseconds < 86400000:
|
|
234
|
+
time.value = Math.floor(elapsedMilliseconds / 3600000);
|
|
235
|
+
time.type = TimeType.Hours;
|
|
236
|
+
break;
|
|
237
|
+
case elapsedMilliseconds < 604800000:
|
|
238
|
+
time.value = Math.floor(elapsedMilliseconds / 86400000);
|
|
239
|
+
time.type = TimeType.Days;
|
|
240
|
+
break;
|
|
241
|
+
case elapsedMilliseconds < 2592000000:
|
|
242
|
+
time.value = Math.floor(elapsedMilliseconds / 604800000);
|
|
243
|
+
time.type = TimeType.Weeks;
|
|
244
|
+
break;
|
|
245
|
+
case elapsedMilliseconds < 31536000000:
|
|
246
|
+
time.value = Math.floor(elapsedMilliseconds / 2592000000);
|
|
247
|
+
time.type = TimeType.Months;
|
|
248
|
+
break;
|
|
249
|
+
default:
|
|
250
|
+
time.value = Math.floor(elapsedMilliseconds / 31536000000);
|
|
251
|
+
time.type = TimeType.Years;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return `${time.value} ${getFormattedPastTimeString(time, language)}`;
|
|
255
|
+
}
|
|
256
|
+
const remainingMilliseconds = date.getTime() - currentDate.getTime();
|
|
257
|
+
switch (true) {
|
|
258
|
+
case remainingMilliseconds < 60000:
|
|
259
|
+
time.value = Math.floor(remainingMilliseconds / 1000);
|
|
260
|
+
time.type = TimeType.Seconds;
|
|
261
|
+
break;
|
|
262
|
+
case remainingMilliseconds < 3600000:
|
|
263
|
+
time.value = Math.floor(remainingMilliseconds / 60000);
|
|
264
|
+
time.type = TimeType.Minutes;
|
|
265
|
+
break;
|
|
266
|
+
case remainingMilliseconds < 86400000:
|
|
267
|
+
time.value = Math.floor(remainingMilliseconds / 3600000);
|
|
268
|
+
time.type = TimeType.Hours;
|
|
269
|
+
break;
|
|
270
|
+
case remainingMilliseconds < 604800000:
|
|
271
|
+
time.value = Math.floor(remainingMilliseconds / 86400000);
|
|
272
|
+
time.type = TimeType.Days;
|
|
273
|
+
break;
|
|
274
|
+
case remainingMilliseconds < 2592000000:
|
|
275
|
+
time.value = Math.floor(remainingMilliseconds / 604800000);
|
|
276
|
+
time.type = TimeType.Weeks;
|
|
277
|
+
break;
|
|
278
|
+
case remainingMilliseconds < 31536000000:
|
|
279
|
+
time.value = Math.floor(remainingMilliseconds / 2592000000);
|
|
280
|
+
time.type = TimeType.Months;
|
|
281
|
+
break;
|
|
282
|
+
default:
|
|
283
|
+
time.value = Math.floor(remainingMilliseconds / 31536000000);
|
|
284
|
+
time.type = TimeType.Years;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
return `${time.value} ${getFormattedFutureTimeString(time, language)}`;
|
|
288
|
+
};
|
|
289
|
+
exports.getTimeTillNow = getTimeTillNow;
|
|
290
|
+
const getFormattedPastTimeString = (time, language) => {
|
|
291
|
+
const {
|
|
292
|
+
value,
|
|
293
|
+
type
|
|
294
|
+
} = time;
|
|
295
|
+
const timeTypeStrings = getTimeTypeStrings(language.code ?? 'de');
|
|
296
|
+
const isSingular = value === 1;
|
|
297
|
+
if (!timeTypeStrings) {
|
|
298
|
+
return '';
|
|
299
|
+
}
|
|
300
|
+
const {
|
|
301
|
+
seconds,
|
|
302
|
+
days,
|
|
303
|
+
weeks,
|
|
304
|
+
months,
|
|
305
|
+
years,
|
|
306
|
+
minutes,
|
|
307
|
+
hours
|
|
308
|
+
} = timeTypeStrings.past;
|
|
309
|
+
switch (true) {
|
|
310
|
+
case type === TimeType.Seconds:
|
|
311
|
+
return isSingular ? seconds.singular : seconds.plural;
|
|
312
|
+
case type === TimeType.Minutes:
|
|
313
|
+
return isSingular ? minutes.singular : minutes.plural;
|
|
314
|
+
case type === TimeType.Hours:
|
|
315
|
+
return isSingular ? hours.singular : hours.plural;
|
|
316
|
+
case type === TimeType.Days:
|
|
317
|
+
return isSingular ? days.singular : days.plural;
|
|
318
|
+
case type === TimeType.Weeks:
|
|
319
|
+
return isSingular ? weeks.singular : weeks.plural;
|
|
320
|
+
case type === TimeType.Months:
|
|
321
|
+
return isSingular ? months.singular : months.plural;
|
|
322
|
+
default:
|
|
323
|
+
return isSingular ? years.singular : years.plural;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
exports.getFormattedPastTimeString = getFormattedPastTimeString;
|
|
327
|
+
const getFormattedFutureTimeString = (time, language) => {
|
|
328
|
+
const {
|
|
329
|
+
value,
|
|
330
|
+
type
|
|
331
|
+
} = time;
|
|
332
|
+
const timeTypeStrings = getTimeTypeStrings(language.code ?? 'de');
|
|
333
|
+
const isSingular = value === 1;
|
|
334
|
+
if (!timeTypeStrings) {
|
|
335
|
+
return '';
|
|
336
|
+
}
|
|
337
|
+
const {
|
|
338
|
+
seconds,
|
|
339
|
+
days,
|
|
340
|
+
weeks,
|
|
341
|
+
months,
|
|
342
|
+
years,
|
|
343
|
+
minutes,
|
|
344
|
+
hours
|
|
345
|
+
} = timeTypeStrings.future;
|
|
346
|
+
switch (true) {
|
|
347
|
+
case type === TimeType.Seconds:
|
|
348
|
+
return isSingular ? seconds.singular : seconds.plural;
|
|
349
|
+
case type === TimeType.Minutes:
|
|
350
|
+
return isSingular ? minutes.singular : minutes.plural;
|
|
351
|
+
case type === TimeType.Hours:
|
|
352
|
+
return isSingular ? hours.singular : hours.plural;
|
|
353
|
+
case type === TimeType.Days:
|
|
354
|
+
return isSingular ? days.singular : days.plural;
|
|
355
|
+
case type === TimeType.Weeks:
|
|
356
|
+
return isSingular ? weeks.singular : weeks.plural;
|
|
357
|
+
case type === TimeType.Months:
|
|
358
|
+
return isSingular ? months.singular : months.plural;
|
|
359
|
+
default:
|
|
360
|
+
return isSingular ? years.singular : years.plural;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
exports.getFormattedFutureTimeString = getFormattedFutureTimeString;
|
|
364
|
+
//# sourceMappingURL=dateInfo.js.map
|