@eliasrrosa/tutorhub-public-assets 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domain/entities/AsaasCustomer.js +1 -5
- package/dist/domain/entities/Class.js +1 -5
- package/dist/domain/entities/ClassRequest.js +1 -2
- package/dist/domain/entities/Contract.js +1 -2
- package/dist/domain/entities/Course.js +1 -2
- package/dist/domain/entities/CourseToSchoolConnectionRequest.js +1 -2
- package/dist/domain/entities/Date.js +1 -2
- package/dist/domain/entities/DateTimeSlot.js +1 -2
- package/dist/domain/entities/DateValidator.js +1 -2
- package/dist/domain/entities/File.js +1 -2
- package/dist/domain/entities/FreeTimeSlot.js +1 -5
- package/dist/domain/entities/GenericNotification.js +1 -2
- package/dist/domain/entities/GoogleAuth.js +1 -2
- package/dist/domain/entities/GoogleCalendar.js +1 -2
- package/dist/domain/entities/GoogleCalendarEvent.js +1 -2
- package/dist/domain/entities/ISO8601Date.js +3 -7
- package/dist/domain/entities/ISO8601Date.test.js +33 -35
- package/dist/domain/entities/ISO8601DateTime.js +1 -5
- package/dist/domain/entities/ISO8601DateTime.test.js +51 -53
- package/dist/domain/entities/ISO8601DateValidator.js +1 -5
- package/dist/domain/entities/ISO8601DateValidator.test.js +3 -5
- package/dist/domain/entities/ISO8601Time.js +3 -7
- package/dist/domain/entities/ISO8601Time.test.js +12 -14
- package/dist/domain/entities/ISO8601TimeValidator.js +1 -5
- package/dist/domain/entities/ISO8601TimeValidator.test.js +2 -4
- package/dist/domain/entities/PasswordRecovery.js +1 -2
- package/dist/domain/entities/Payment.js +1 -2
- package/dist/domain/entities/PaymentRecognitionRequest.js +1 -2
- package/dist/domain/entities/PreApprovedUser.js +1 -2
- package/dist/domain/entities/RescheduleRequest.js +1 -2
- package/dist/domain/entities/School.js +1 -2
- package/dist/domain/entities/SchoolConnection.js +1 -2
- package/dist/domain/entities/SchoolConnectionRequest.js +1 -2
- package/dist/domain/entities/SchoolStudent.js +1 -2
- package/dist/domain/entities/SchoolTeacher.js +1 -2
- package/dist/domain/entities/Time.js +1 -2
- package/dist/domain/entities/TimeSlot.js +1 -2
- package/dist/domain/entities/TimeValidator.js +1 -2
- package/dist/domain/entities/UnauthorizedUser.js +1 -2
- package/dist/domain/entities/UserAuth.js +1 -2
- package/dist/domain/entities/UserConnection.js +1 -2
- package/dist/domain/entities/UserConnectionRequest.js +1 -2
- package/dist/domain/entities/UserCredentials.js +1 -5
- package/dist/domain/entities/UserNavigation.js +1 -2
- package/dist/domain/entities/UserPreferences.js +1 -2
- package/dist/domain/entities/UserPremium.js +1 -2
- package/dist/domain/entities/UserProfile.js +1 -2
- package/dist/domain/entities/UserRoles.js +1 -2
- package/dist/domain/entities/UserSharedFileTimestamps.js +1 -2
- package/dist/domain/entities/UserUnavailableTime.js +1 -5
- package/dist/domain/entities/UserUnavailableTime.test.js +4 -6
- package/dist/domain/repositories/UnavailableTimeRepository.js +1 -2
- package/dist/index.d.ts +48 -0
- package/dist/index.js +10 -0
- package/dist/restful/responses/GetFixedAvailableTimesResponseBody.js +1 -2
- package/package.json +9 -3
- package/dist/entities/AsaasCustomer.d.ts +0 -14
- package/dist/entities/AsaasCustomer.js +0 -13
- package/dist/entities/Class.d.ts +0 -79
- package/dist/entities/Class.js +0 -30
- package/dist/entities/ClassRequest.d.ts +0 -15
- package/dist/entities/ClassRequest.js +0 -2
- package/dist/entities/Contract.d.ts +0 -40
- package/dist/entities/Contract.js +0 -2
- package/dist/entities/Course.d.ts +0 -34
- package/dist/entities/Course.js +0 -2
- package/dist/entities/CourseToSchoolConnectionRequest.d.ts +0 -10
- package/dist/entities/CourseToSchoolConnectionRequest.js +0 -2
- package/dist/entities/Date.d.ts +0 -56
- package/dist/entities/Date.js +0 -2
- package/dist/entities/Date.test.d.ts +0 -0
- package/dist/entities/Date.test.js +0 -23
- package/dist/entities/DateTimeSlot.d.ts +0 -6
- package/dist/entities/DateTimeSlot.js +0 -2
- package/dist/entities/DateValidator.d.ts +0 -3
- package/dist/entities/DateValidator.js +0 -2
- package/dist/entities/File.d.ts +0 -23
- package/dist/entities/File.js +0 -2
- package/dist/entities/FreeTimeSlot.d.ts +0 -19
- package/dist/entities/FreeTimeSlot.js +0 -12
- package/dist/entities/GenericNotification.d.ts +0 -11
- package/dist/entities/GenericNotification.js +0 -2
- package/dist/entities/GoogleAuth.d.ts +0 -8
- package/dist/entities/GoogleAuth.js +0 -2
- package/dist/entities/GoogleCalendar.d.ts +0 -10
- package/dist/entities/GoogleCalendar.js +0 -2
- package/dist/entities/GoogleCalendarEvent.d.ts +0 -10
- package/dist/entities/GoogleCalendarEvent.js +0 -2
- package/dist/entities/ISO8601Date.d.ts +0 -35
- package/dist/entities/ISO8601Date.js +0 -86
- package/dist/entities/ISO8601Date.test.d.ts +0 -1
- package/dist/entities/ISO8601Date.test.js +0 -210
- package/dist/entities/ISO8601DateTime.d.ts +0 -41
- package/dist/entities/ISO8601DateTime.js +0 -44
- package/dist/entities/ISO8601DateTime.test.d.ts +0 -1
- package/dist/entities/ISO8601DateTime.test.js +0 -146
- package/dist/entities/ISO8601DateValidator.d.ts +0 -13
- package/dist/entities/ISO8601DateValidator.js +0 -20
- package/dist/entities/ISO8601DateValidator.test.d.ts +0 -1
- package/dist/entities/ISO8601DateValidator.test.js +0 -15
- package/dist/entities/ISO8601Time.d.ts +0 -25
- package/dist/entities/ISO8601Time.js +0 -57
- package/dist/entities/ISO8601Time.test.d.ts +0 -1
- package/dist/entities/ISO8601Time.test.js +0 -63
- package/dist/entities/ISO8601TimeValidator.d.ts +0 -12
- package/dist/entities/ISO8601TimeValidator.js +0 -19
- package/dist/entities/ISO8601TimeValidator.test.d.ts +0 -1
- package/dist/entities/ISO8601TimeValidator.test.js +0 -42
- package/dist/entities/PasswordRecovery.d.ts +0 -6
- package/dist/entities/PasswordRecovery.js +0 -2
- package/dist/entities/Payment.d.ts +0 -42
- package/dist/entities/Payment.js +0 -2
- package/dist/entities/PaymentRecognitionRequest.d.ts +0 -12
- package/dist/entities/PaymentRecognitionRequest.js +0 -2
- package/dist/entities/PreApprovedUser.d.ts +0 -12
- package/dist/entities/PreApprovedUser.js +0 -2
- package/dist/entities/RescheduleRequest.d.ts +0 -16
- package/dist/entities/RescheduleRequest.js +0 -2
- package/dist/entities/School.d.ts +0 -31
- package/dist/entities/School.js +0 -2
- package/dist/entities/SchoolConnection.d.ts +0 -10
- package/dist/entities/SchoolConnection.js +0 -2
- package/dist/entities/SchoolConnectionRequest.d.ts +0 -7
- package/dist/entities/SchoolConnectionRequest.js +0 -2
- package/dist/entities/SchoolStudent.d.ts +0 -14
- package/dist/entities/SchoolStudent.js +0 -2
- package/dist/entities/SchoolTeacher.d.ts +0 -14
- package/dist/entities/SchoolTeacher.js +0 -2
- package/dist/entities/Time.d.ts +0 -9
- package/dist/entities/Time.js +0 -2
- package/dist/entities/TimeSlot.d.ts +0 -4
- package/dist/entities/TimeSlot.js +0 -2
- package/dist/entities/TimeValidator.d.ts +0 -3
- package/dist/entities/TimeValidator.js +0 -2
- package/dist/entities/UnauthorizedUser.d.ts +0 -16
- package/dist/entities/UnauthorizedUser.js +0 -2
- package/dist/entities/UserAuth.d.ts +0 -72
- package/dist/entities/UserAuth.js +0 -2
- package/dist/entities/UserConnection.d.ts +0 -8
- package/dist/entities/UserConnection.js +0 -2
- package/dist/entities/UserConnectionRequest.d.ts +0 -9
- package/dist/entities/UserConnectionRequest.js +0 -2
- package/dist/entities/UserCredentials.d.ts +0 -16
- package/dist/entities/UserCredentials.js +0 -11
- package/dist/entities/UserNavigation.d.ts +0 -8
- package/dist/entities/UserNavigation.js +0 -2
- package/dist/entities/UserPreferences.d.ts +0 -6
- package/dist/entities/UserPreferences.js +0 -2
- package/dist/entities/UserPremium.d.ts +0 -13
- package/dist/entities/UserPremium.js +0 -2
- package/dist/entities/UserProfile.d.ts +0 -9
- package/dist/entities/UserProfile.js +0 -2
- package/dist/entities/UserRoles.d.ts +0 -11
- package/dist/entities/UserRoles.js +0 -2
- package/dist/entities/UserSharedFileTimestamps.d.ts +0 -9
- package/dist/entities/UserSharedFileTimestamps.js +0 -2
- package/dist/entities/UserUnavailableTime.d.ts +0 -49
- package/dist/entities/UserUnavailableTime.js +0 -32
- package/dist/entities/UserUnavailableTime.test.d.ts +0 -1
- package/dist/entities/UserUnavailableTime.test.js +0 -22
- package/dist/repositories/UnavailableTimeRepository.d.ts +0 -20
- package/dist/repositories/UnavailableTimeRepository.js +0 -2
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsaasCustomer = void 0;
|
|
4
|
-
class AsaasCustomer {
|
|
1
|
+
export class AsaasCustomer {
|
|
5
2
|
constructor(opts) {
|
|
6
3
|
this.name = opts.name;
|
|
7
4
|
this.cpfCnpj = opts.cpfCnpj;
|
|
@@ -10,4 +7,3 @@ class AsaasCustomer {
|
|
|
10
7
|
this.externalReference = opts.externalReference;
|
|
11
8
|
}
|
|
12
9
|
}
|
|
13
|
-
exports.AsaasCustomer = AsaasCustomer;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Class = void 0;
|
|
4
|
-
class Class {
|
|
1
|
+
export class Class {
|
|
5
2
|
constructor(params) {
|
|
6
3
|
this.id = params.id;
|
|
7
4
|
this.groupId = params.groupId ? params.groupId : null;
|
|
@@ -27,4 +24,3 @@ class Class {
|
|
|
27
24
|
this.ownerId = params.ownerId;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.Class = Class;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FreeDateTimeSlot = void 0;
|
|
4
|
-
class FreeDateTimeSlot {
|
|
1
|
+
export class FreeDateTimeSlot {
|
|
5
2
|
constructor(opts) {
|
|
6
3
|
this.date = opts.date;
|
|
7
4
|
this.startTime = opts.startTime;
|
|
@@ -9,4 +6,3 @@ class FreeDateTimeSlot {
|
|
|
9
6
|
this.userId = opts.userId;
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.FreeDateTimeSlot = FreeDateTimeSlot;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ISO8601Date = void 0;
|
|
4
|
-
const ISO8601DateValidator_1 = require("./ISO8601DateValidator");
|
|
5
|
-
class ISO8601Date {
|
|
1
|
+
import { ISO8601DateValidator } from "./ISO8601DateValidator";
|
|
2
|
+
export class ISO8601Date {
|
|
6
3
|
constructor(value) {
|
|
7
|
-
this.validator = new
|
|
4
|
+
this.validator = new ISO8601DateValidator();
|
|
8
5
|
this.getDay = () => {
|
|
9
6
|
this.throwIfFormatIsNotValid();
|
|
10
7
|
return this.value.split("-")[2];
|
|
@@ -68,7 +65,6 @@ class ISO8601Date {
|
|
|
68
65
|
return `${year}-${month}-${day}`;
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
|
-
exports.ISO8601Date = ISO8601Date;
|
|
72
68
|
/**
|
|
73
69
|
* Converts a Javascript Date instance into an IDate instance. Uses local timezone as default.
|
|
74
70
|
* @param useUtc set to `true` to consider UTC when extracting year, month and date
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ISO8601Date_1 = require("./ISO8601Date");
|
|
1
|
+
import { ISO8601Date } from "./ISO8601Date";
|
|
4
2
|
describe("ISO8601Date", () => {
|
|
5
3
|
describe("ISO8601Date constructor", () => {
|
|
6
4
|
beforeEach(() => {
|
|
@@ -10,21 +8,21 @@ describe("ISO8601Date", () => {
|
|
|
10
8
|
jest.useRealTimers();
|
|
11
9
|
});
|
|
12
10
|
it("Should construct if date is valid", () => {
|
|
13
|
-
const date = new
|
|
11
|
+
const date = new ISO8601Date("2025-01-01");
|
|
14
12
|
expect(date.value).toBe("2025-01-01");
|
|
15
13
|
});
|
|
16
14
|
it("Should throw if value is not valid", () => {
|
|
17
15
|
const instantiateDate = () => {
|
|
18
|
-
new
|
|
16
|
+
new ISO8601Date("2025-01-011");
|
|
19
17
|
};
|
|
20
18
|
expect(instantiateDate).toThrow();
|
|
21
19
|
});
|
|
22
20
|
it("Should construct with no arguments.", () => {
|
|
23
|
-
const date = new
|
|
21
|
+
const date = new ISO8601Date();
|
|
24
22
|
expect(date).toBeDefined();
|
|
25
23
|
});
|
|
26
24
|
it("Should have value set as today when constructed with no arguments.", () => {
|
|
27
|
-
const date = new
|
|
25
|
+
const date = new ISO8601Date();
|
|
28
26
|
expect(date.value).toBe("2025-01-01");
|
|
29
27
|
const validateFormat = () => {
|
|
30
28
|
return date.validator.formatIsValid(date.value);
|
|
@@ -34,45 +32,45 @@ describe("ISO8601Date", () => {
|
|
|
34
32
|
});
|
|
35
33
|
describe("ISO8601Date.getDay()", () => {
|
|
36
34
|
it("Should return the day if format is valid.", () => {
|
|
37
|
-
const date = new
|
|
35
|
+
const date = new ISO8601Date("2025-01-02");
|
|
38
36
|
expect(date.getDay()).toBe("02");
|
|
39
37
|
});
|
|
40
38
|
});
|
|
41
39
|
describe("ISO8601Date.getMonth()", () => {
|
|
42
40
|
it("Should return the month if format is valid.", () => {
|
|
43
|
-
const date = new
|
|
41
|
+
const date = new ISO8601Date("2025-01-02");
|
|
44
42
|
expect(date.getMonth()).toBe("01");
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
45
|
describe("ISO8601Date.getYear()", () => {
|
|
48
46
|
it("Should return the year if format is valid.", () => {
|
|
49
|
-
const date = new
|
|
47
|
+
const date = new ISO8601Date("2025-01-02");
|
|
50
48
|
expect(date.getYear()).toBe("2025");
|
|
51
49
|
});
|
|
52
50
|
});
|
|
53
51
|
describe("ISO8601Date.addDays()", () => {
|
|
54
52
|
it("Should add days resulting in the same month", () => {
|
|
55
|
-
const date = new
|
|
53
|
+
const date = new ISO8601Date("2025-01-02");
|
|
56
54
|
expect(date.addDays(10).value).toBe("2025-01-12");
|
|
57
55
|
});
|
|
58
56
|
it("Should add days resulting in the next month", () => {
|
|
59
|
-
const date = new
|
|
57
|
+
const date = new ISO8601Date("2025-01-01");
|
|
60
58
|
expect(date.addDays(31).value).toBe("2025-02-01");
|
|
61
59
|
});
|
|
62
60
|
it("Should add days resulting in multiple months ahead", () => {
|
|
63
|
-
const date = new
|
|
61
|
+
const date = new ISO8601Date("2025-03-01");
|
|
64
62
|
expect(date.addDays(31 + 30 + 31 + 3).value).toBe("2025-06-04");
|
|
65
63
|
});
|
|
66
64
|
it("Should add days resulting in multiple months ahead", () => {
|
|
67
|
-
const date = new
|
|
65
|
+
const date = new ISO8601Date("2025-03-01");
|
|
68
66
|
expect(date.addDays(31 + 30 + 31 + 3).value).toBe("2025-06-04");
|
|
69
67
|
});
|
|
70
68
|
it("Should be chainable.", () => {
|
|
71
|
-
const date = new
|
|
69
|
+
const date = new ISO8601Date("2025-03-01");
|
|
72
70
|
expect(date.addDays(31).addDays(30).addDays(31).addDays(3).value).toBe("2025-06-04");
|
|
73
71
|
});
|
|
74
72
|
it("Should accept negative values", () => {
|
|
75
|
-
const date = new
|
|
73
|
+
const date = new ISO8601Date("2025-03-02");
|
|
76
74
|
expect(date.addDays(-1).value).toBe("2025-03-01");
|
|
77
75
|
});
|
|
78
76
|
describe("ISO8601Date.addDays() in a timezone ahead of UTC", () => {
|
|
@@ -85,43 +83,43 @@ describe("ISO8601Date", () => {
|
|
|
85
83
|
jest.useRealTimers();
|
|
86
84
|
});
|
|
87
85
|
it("Should add days resulting in the same month", () => {
|
|
88
|
-
const date = new
|
|
86
|
+
const date = new ISO8601Date("2025-01-02");
|
|
89
87
|
expect(date.addDays(10).value).toBe("2025-01-12");
|
|
90
88
|
});
|
|
91
89
|
it("Should add days resulting in the next month", () => {
|
|
92
|
-
const date = new
|
|
90
|
+
const date = new ISO8601Date("2025-01-01");
|
|
93
91
|
expect(date.addDays(31).value).toBe("2025-02-01");
|
|
94
92
|
});
|
|
95
93
|
it("Should add days resulting in multiple months ahead", () => {
|
|
96
|
-
const date = new
|
|
94
|
+
const date = new ISO8601Date("2025-03-01");
|
|
97
95
|
expect(date.addDays(31 + 30 + 31 + 3).value).toBe("2025-06-04");
|
|
98
96
|
});
|
|
99
97
|
it("Should add days resulting in multiple months ahead", () => {
|
|
100
|
-
const date = new
|
|
98
|
+
const date = new ISO8601Date("2025-03-01");
|
|
101
99
|
expect(date.addDays(31 + 30 + 31 + 3).value).toBe("2025-06-04");
|
|
102
100
|
});
|
|
103
101
|
it("Should be chainable.", () => {
|
|
104
|
-
const date = new
|
|
102
|
+
const date = new ISO8601Date("2025-03-01");
|
|
105
103
|
expect(date.addDays(31).addDays(30).addDays(31).addDays(3).value).toBe("2025-06-04");
|
|
106
104
|
});
|
|
107
105
|
});
|
|
108
106
|
});
|
|
109
107
|
describe("ISO8601Date.jsDateTimeToDate()", () => {
|
|
110
108
|
it("Should return an IDate instance", () => {
|
|
111
|
-
expect(
|
|
109
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date(2025, 5, 4))).toBeInstanceOf(ISO8601Date);
|
|
112
110
|
});
|
|
113
111
|
it("Should return expected value in ISO8601 format.", () => {
|
|
114
|
-
expect(
|
|
115
|
-
expect(
|
|
112
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date(2025, 5, 4)).value).toBe("2025-06-04");
|
|
113
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date(2025, 0, 1)).value).toBe("2025-01-01");
|
|
116
114
|
});
|
|
117
115
|
it("If js date is in UTC (created without timezone and with a string) and converting would cause a change of date, should return date changed.", () => {
|
|
118
|
-
expect(
|
|
116
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date("2025-06-04")).value).toBe("2025-06-03");
|
|
119
117
|
});
|
|
120
118
|
it("If js date is in UTC (created with timezone and with a string) and converting would cause a change of date, should return date changed.", () => {
|
|
121
|
-
expect(
|
|
119
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date("2025-06-04T00:00:00Z")).value).toBe("2025-06-03");
|
|
122
120
|
});
|
|
123
121
|
it("If js date is in UTC and useUtc param is true, should return utc date.", () => {
|
|
124
|
-
expect(
|
|
122
|
+
expect(ISO8601Date.jsDateTimeToDate(new Date("2025-06-04T00:00:00Z"), {
|
|
125
123
|
useUtc: true,
|
|
126
124
|
}).value).toBe("2025-06-04");
|
|
127
125
|
});
|
|
@@ -132,16 +130,16 @@ describe("ISO8601Date", () => {
|
|
|
132
130
|
});
|
|
133
131
|
it("Should return today's date properly with different timezones", () => {
|
|
134
132
|
jest.useFakeTimers().setSystemTime(new Date("2025-01-01T23:00:00-03:00"));
|
|
135
|
-
expect(
|
|
133
|
+
expect(ISO8601Date.getToday()).toBe("2025-01-01");
|
|
136
134
|
jest.setSystemTime(new Date("2025-01-02T23:00:00+03:00"));
|
|
137
|
-
expect(
|
|
135
|
+
expect(ISO8601Date.getToday()).toBe("2025-01-02");
|
|
138
136
|
jest.setSystemTime(new Date("2025-01-04T23:00:00+12:00"));
|
|
139
|
-
expect(
|
|
137
|
+
expect(ISO8601Date.getToday()).toBe("2025-01-04");
|
|
140
138
|
});
|
|
141
139
|
});
|
|
142
140
|
describe("ISO8601Date.toLocalJsDateTime()", () => {
|
|
143
141
|
it("Should return js date time of same day, month and year, considering local time.", () => {
|
|
144
|
-
const date = new
|
|
142
|
+
const date = new ISO8601Date("2025-01-01").toLocalJsDateTime();
|
|
145
143
|
expect(date.getMonth()).toEqual(0);
|
|
146
144
|
expect(date.getDate()).toEqual(1);
|
|
147
145
|
expect(date.getFullYear()).toEqual(2025);
|
|
@@ -156,7 +154,7 @@ describe("ISO8601Date", () => {
|
|
|
156
154
|
});
|
|
157
155
|
it("Should return js date time of same day, month and year, considering utc time.", () => {
|
|
158
156
|
jest.useFakeTimers().setSystemTime(new Date("2025-01-01T00:00:00Z"));
|
|
159
|
-
const date = new
|
|
157
|
+
const date = new ISO8601Date("2025-01-01").toUtcJsDateTime();
|
|
160
158
|
expect(date).toBeInstanceOf(Date);
|
|
161
159
|
expect(date.getUTCMonth()).toEqual(0);
|
|
162
160
|
expect(date.getUTCDate()).toEqual(1);
|
|
@@ -168,12 +166,12 @@ describe("ISO8601Date", () => {
|
|
|
168
166
|
});
|
|
169
167
|
describe("ISO8601Date.getDaysSinceEpoch()", () => {
|
|
170
168
|
it("Should return expected days count", () => {
|
|
171
|
-
const days = new
|
|
169
|
+
const days = new ISO8601Date("1970-01-02").getDaysSinceEpoch();
|
|
172
170
|
expect(days).toEqual(1);
|
|
173
171
|
});
|
|
174
172
|
it("From a UTC date, should return expected days count", () => {
|
|
175
173
|
const utcDate = new Date("1970-01-02T00:00:00Z");
|
|
176
|
-
const days = new
|
|
174
|
+
const days = new ISO8601Date()
|
|
177
175
|
.jsDateTimeToDate(utcDate, { useUtc: true })
|
|
178
176
|
.getDaysSinceEpoch();
|
|
179
177
|
expect(days).toEqual(1);
|
|
@@ -184,7 +182,7 @@ describe("ISO8601Date", () => {
|
|
|
184
182
|
jest.useRealTimers();
|
|
185
183
|
});
|
|
186
184
|
jest.useFakeTimers().setSystemTime(new Date("2025-04-21"));
|
|
187
|
-
const today = new
|
|
185
|
+
const today = new ISO8601Date();
|
|
188
186
|
it("Should return 0 for Monday.", () => {
|
|
189
187
|
expect(today.getDayOfTheWeek()).toEqual(0);
|
|
190
188
|
});
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ISO8601DateTime = void 0;
|
|
4
|
-
class ISO8601DateTime {
|
|
1
|
+
export class ISO8601DateTime {
|
|
5
2
|
constructor(opts) {
|
|
6
3
|
this.getJSDateTime = () => {
|
|
7
4
|
return new Date(parseInt(this.date.getYear()), parseInt(this.date.getMonth()) - 1, parseInt(this.date.getDay()), parseInt(this.time.getHours()), parseInt(this.time.getMinutes()), parseInt(this.time.getSeconds()));
|
|
@@ -41,4 +38,3 @@ class ISO8601DateTime {
|
|
|
41
38
|
return `${year}-${month}-${day}T${hour}:${minute}:${second}${timezone}`;
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
exports.ISO8601DateTime = ISO8601DateTime;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ISO8601DateTime_1 = require("./ISO8601DateTime");
|
|
5
|
-
const ISO8601Time_1 = require("./ISO8601Time");
|
|
1
|
+
import { ISO8601Date } from "./ISO8601Date";
|
|
2
|
+
import { ISO8601DateTime } from "./ISO8601DateTime";
|
|
3
|
+
import { ISO8601Time } from "./ISO8601Time";
|
|
6
4
|
describe("ISO8601DateTime", () => {
|
|
7
5
|
describe("ISO8601DateTime getJSDateTime()", () => {
|
|
8
6
|
it("Should return a JS Date object.", () => {
|
|
9
|
-
const dateTime = new
|
|
10
|
-
date: new
|
|
11
|
-
time: new
|
|
7
|
+
const dateTime = new ISO8601DateTime({
|
|
8
|
+
date: new ISO8601Date("2025-01-01"),
|
|
9
|
+
time: new ISO8601Time("10:00:00"),
|
|
12
10
|
});
|
|
13
11
|
const jsDateTime = dateTime.getJSDateTime();
|
|
14
12
|
expect(jsDateTime).toBeInstanceOf(Date);
|
|
15
13
|
});
|
|
16
14
|
it("Should return the same year, month and day when returning UTC date.", () => {
|
|
17
|
-
const dateTime = new
|
|
18
|
-
date: new
|
|
19
|
-
time: new
|
|
15
|
+
const dateTime = new ISO8601DateTime({
|
|
16
|
+
date: new ISO8601Date("2025-01-02"),
|
|
17
|
+
time: new ISO8601Time("00:00:00"),
|
|
20
18
|
});
|
|
21
19
|
const jsDateTime = dateTime.getJSDateTime();
|
|
22
20
|
expect(jsDateTime.getUTCDate()).toBe(2);
|
|
@@ -24,17 +22,17 @@ describe("ISO8601DateTime", () => {
|
|
|
24
22
|
expect(jsDateTime.getUTCFullYear()).toBe(2025);
|
|
25
23
|
});
|
|
26
24
|
it("Should return locale date string of same date and time as constructed.", () => {
|
|
27
|
-
const dateTime = new
|
|
28
|
-
date: new
|
|
29
|
-
time: new
|
|
25
|
+
const dateTime = new ISO8601DateTime({
|
|
26
|
+
date: new ISO8601Date("2025-01-02"),
|
|
27
|
+
time: new ISO8601Time("01:02:03"),
|
|
30
28
|
});
|
|
31
29
|
const jsDateTime = dateTime.getJSDateTime();
|
|
32
30
|
expect(jsDateTime.toLocaleDateString("pt-BR")).toBe("02/01/2025");
|
|
33
31
|
});
|
|
34
32
|
it("Should return ISO string converted to UTC.", () => {
|
|
35
|
-
const dateTime = new
|
|
36
|
-
date: new
|
|
37
|
-
time: new
|
|
33
|
+
const dateTime = new ISO8601DateTime({
|
|
34
|
+
date: new ISO8601Date("2025-01-02"),
|
|
35
|
+
time: new ISO8601Time("01:02:03"),
|
|
38
36
|
});
|
|
39
37
|
const jsDateTime = dateTime.getJSDateTime();
|
|
40
38
|
expect(jsDateTime.toISOString()).toBe("2025-01-02T04:02:03.000Z");
|
|
@@ -42,9 +40,9 @@ describe("ISO8601DateTime", () => {
|
|
|
42
40
|
});
|
|
43
41
|
describe("ISO8601DateTime.getBrazilianIsoString()", () => {
|
|
44
42
|
it("Should return ISO string converted to Brazilian time.", () => {
|
|
45
|
-
const dateTime = new
|
|
46
|
-
date: new
|
|
47
|
-
time: new
|
|
43
|
+
const dateTime = new ISO8601DateTime({
|
|
44
|
+
date: new ISO8601Date("2025-01-02"),
|
|
45
|
+
time: new ISO8601Time("01:02:03"),
|
|
48
46
|
});
|
|
49
47
|
const brazilianIsoString = dateTime.getBrazilianIsoString();
|
|
50
48
|
expect(brazilianIsoString).toBe("2025-01-02T01:02:03-03:00");
|
|
@@ -52,25 +50,25 @@ describe("ISO8601DateTime", () => {
|
|
|
52
50
|
});
|
|
53
51
|
describe("ISO8601DateTime.getIsoString()", () => {
|
|
54
52
|
it("Should return ISO UTC string if no arguments.", () => {
|
|
55
|
-
const dateTime = new
|
|
56
|
-
date: new
|
|
57
|
-
time: new
|
|
53
|
+
const dateTime = new ISO8601DateTime({
|
|
54
|
+
date: new ISO8601Date("2025-01-02"),
|
|
55
|
+
time: new ISO8601Time("03:01:02"),
|
|
58
56
|
});
|
|
59
57
|
const utcIsoString = dateTime.getIsoString();
|
|
60
58
|
expect(utcIsoString).toBe("2025-01-02T03:01:02.000Z");
|
|
61
59
|
});
|
|
62
60
|
it("Should return ISO string +01:00 for London timezone.", () => {
|
|
63
|
-
const dateTime = new
|
|
64
|
-
date: new
|
|
65
|
-
time: new
|
|
61
|
+
const dateTime = new ISO8601DateTime({
|
|
62
|
+
date: new ISO8601Date("2025-01-02"),
|
|
63
|
+
time: new ISO8601Time("03:01:02"),
|
|
66
64
|
});
|
|
67
65
|
const isoString = dateTime.getIsoString({ timezoneOffsetMinutes: 60 });
|
|
68
66
|
expect(isoString).toBe("2025-01-02T03:01:02+01:00");
|
|
69
67
|
});
|
|
70
68
|
it("Should return ISO string -05:00 for Chicago DST timezone.", () => {
|
|
71
|
-
const dateTime = new
|
|
72
|
-
date: new
|
|
73
|
-
time: new
|
|
69
|
+
const dateTime = new ISO8601DateTime({
|
|
70
|
+
date: new ISO8601Date("2025-01-02"),
|
|
71
|
+
time: new ISO8601Time("03:01:02"),
|
|
74
72
|
});
|
|
75
73
|
const isoString = dateTime.getIsoString({
|
|
76
74
|
timezoneOffsetMinutes: -300,
|
|
@@ -78,9 +76,9 @@ describe("ISO8601DateTime", () => {
|
|
|
78
76
|
expect(isoString).toBe("2025-01-02T03:01:02-05:00");
|
|
79
77
|
});
|
|
80
78
|
it("Should return ISO string -03:00 for Brazilian timezone.", () => {
|
|
81
|
-
const dateTime = new
|
|
82
|
-
date: new
|
|
83
|
-
time: new
|
|
79
|
+
const dateTime = new ISO8601DateTime({
|
|
80
|
+
date: new ISO8601Date("2025-01-02"),
|
|
81
|
+
time: new ISO8601Time("03:01:02"),
|
|
84
82
|
});
|
|
85
83
|
const isoString = dateTime.getIsoString({
|
|
86
84
|
timezoneOffsetMinutes: -180,
|
|
@@ -88,9 +86,9 @@ describe("ISO8601DateTime", () => {
|
|
|
88
86
|
expect(isoString).toBe("2025-01-02T03:01:02-03:00");
|
|
89
87
|
});
|
|
90
88
|
it("Should return ISO string -03:00 for Brazilian timezone derived from Date.", () => {
|
|
91
|
-
const dateTime = new
|
|
92
|
-
date: new
|
|
93
|
-
time: new
|
|
89
|
+
const dateTime = new ISO8601DateTime({
|
|
90
|
+
date: new ISO8601Date("2025-01-02"),
|
|
91
|
+
time: new ISO8601Time("03:01:02"),
|
|
94
92
|
});
|
|
95
93
|
const isoString = dateTime.getIsoString({
|
|
96
94
|
timezoneOffsetMinutes: -new Date().getTimezoneOffset(),
|
|
@@ -98,47 +96,47 @@ describe("ISO8601DateTime", () => {
|
|
|
98
96
|
expect(isoString).toBe("2025-01-02T03:01:02-03:00");
|
|
99
97
|
});
|
|
100
98
|
it("Should accept newDate and properly output it.", () => {
|
|
101
|
-
const dateTime = new
|
|
102
|
-
date: new
|
|
103
|
-
time: new
|
|
99
|
+
const dateTime = new ISO8601DateTime({
|
|
100
|
+
date: new ISO8601Date("2025-01-02"),
|
|
101
|
+
time: new ISO8601Time("03:01:02"),
|
|
104
102
|
});
|
|
105
103
|
const isoString = dateTime.getIsoString({
|
|
106
104
|
timezoneOffsetMinutes: -new Date().getTimezoneOffset(),
|
|
107
|
-
newDate: new
|
|
105
|
+
newDate: new ISO8601Date("2025-01-03"),
|
|
108
106
|
});
|
|
109
107
|
expect(isoString).toBe("2025-01-03T03:01:02-03:00");
|
|
110
108
|
});
|
|
111
109
|
it("Should accept newTime and properly output it.", () => {
|
|
112
|
-
const dateTime = new
|
|
113
|
-
date: new
|
|
114
|
-
time: new
|
|
110
|
+
const dateTime = new ISO8601DateTime({
|
|
111
|
+
date: new ISO8601Date("2025-01-02"),
|
|
112
|
+
time: new ISO8601Time("03:01:02"),
|
|
115
113
|
});
|
|
116
114
|
const isoString = dateTime.getIsoString({
|
|
117
115
|
timezoneOffsetMinutes: -new Date().getTimezoneOffset(),
|
|
118
|
-
newTime: new
|
|
116
|
+
newTime: new ISO8601Time("03:01:03")
|
|
119
117
|
});
|
|
120
118
|
expect(isoString).toBe("2025-01-02T03:01:03-03:00");
|
|
121
119
|
});
|
|
122
120
|
it("Should accept newTime and newDate and properly output them.", () => {
|
|
123
|
-
const dateTime = new
|
|
124
|
-
date: new
|
|
125
|
-
time: new
|
|
121
|
+
const dateTime = new ISO8601DateTime({
|
|
122
|
+
date: new ISO8601Date("2025-01-02"),
|
|
123
|
+
time: new ISO8601Time("03:01:02"),
|
|
126
124
|
});
|
|
127
125
|
const isoString = dateTime.getIsoString({
|
|
128
126
|
timezoneOffsetMinutes: -new Date().getTimezoneOffset(),
|
|
129
|
-
newTime: new
|
|
130
|
-
newDate: new
|
|
127
|
+
newTime: new ISO8601Time("03:01:03"),
|
|
128
|
+
newDate: new ISO8601Date("2025-01-03")
|
|
131
129
|
});
|
|
132
130
|
expect(isoString).toBe("2025-01-03T03:01:03-03:00");
|
|
133
131
|
});
|
|
134
132
|
it("Should accept newTime and newDate and properly output them, even when timezone is UTC.", () => {
|
|
135
|
-
const dateTime = new
|
|
136
|
-
date: new
|
|
137
|
-
time: new
|
|
133
|
+
const dateTime = new ISO8601DateTime({
|
|
134
|
+
date: new ISO8601Date("2025-01-02"),
|
|
135
|
+
time: new ISO8601Time("03:01:02"),
|
|
138
136
|
});
|
|
139
137
|
const isoString = dateTime.getIsoString({
|
|
140
|
-
newTime: new
|
|
141
|
-
newDate: new
|
|
138
|
+
newTime: new ISO8601Time("03:01:03"),
|
|
139
|
+
newDate: new ISO8601Date("2025-01-03")
|
|
142
140
|
});
|
|
143
141
|
expect(isoString).toBe("2025-01-03T03:01:03.000Z");
|
|
144
142
|
});
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ISO8601DateValidator = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Accepted format: YYYY-MM-DD
|
|
6
3
|
* @throws on construction if format is wrong
|
|
7
4
|
* @throws on get methods if format is wrong
|
|
8
5
|
*/
|
|
9
|
-
class ISO8601DateValidator {
|
|
6
|
+
export class ISO8601DateValidator {
|
|
10
7
|
constructor() {
|
|
11
8
|
this.YYYYmmDD = new RegExp("^[0-9]{4}-([0][1-9]|[1][0-2])-([0][1-9]|[1-2][0-9]|[3][0-1])$");
|
|
12
9
|
}
|
|
@@ -17,4 +14,3 @@ class ISO8601DateValidator {
|
|
|
17
14
|
return this.YYYYmmDD.test(date);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.ISO8601DateValidator = ISO8601DateValidator;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ISO8601DateValidator_1 = require("./ISO8601DateValidator");
|
|
1
|
+
import { ISO8601DateValidator } from "./ISO8601DateValidator";
|
|
4
2
|
describe("ISO8601DateValidator", () => {
|
|
5
3
|
describe("ISO8601DateValidator.formatIsValid()", () => {
|
|
6
4
|
it("Should return true if format is YYYY-MM-DD.", () => {
|
|
7
|
-
const date = new
|
|
5
|
+
const date = new ISO8601DateValidator();
|
|
8
6
|
expect(date.formatIsValid("2025-01-01")).toBe(true);
|
|
9
7
|
});
|
|
10
8
|
it("Should return false if format is not YYYY-MM-DD.", () => {
|
|
11
|
-
const date = new
|
|
9
|
+
const date = new ISO8601DateValidator();
|
|
12
10
|
expect(date.formatIsValid("2025-01-011")).toBe(false);
|
|
13
11
|
});
|
|
14
12
|
});
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ISO8601Time = void 0;
|
|
4
|
-
const ISO8601TimeValidator_1 = require("./ISO8601TimeValidator");
|
|
1
|
+
import { ISO8601TimeValidator } from "./ISO8601TimeValidator";
|
|
5
2
|
/**
|
|
6
3
|
* Interface for interacting with ISO8601 time formats.
|
|
7
4
|
* Accepted formats: HH:MM:SS and HH:MM.
|
|
@@ -9,13 +6,13 @@ const ISO8601TimeValidator_1 = require("./ISO8601TimeValidator");
|
|
|
9
6
|
* @throws if instantiated with a different format
|
|
10
7
|
* @throws if any method is called with a different format
|
|
11
8
|
*/
|
|
12
|
-
class ISO8601Time {
|
|
9
|
+
export class ISO8601Time {
|
|
13
10
|
/**
|
|
14
11
|
* Throws if format is invalid.
|
|
15
12
|
* Accepted formats: HH:MM:SS and HH:MM.
|
|
16
13
|
*/
|
|
17
14
|
constructor(value) {
|
|
18
|
-
this.validator = new
|
|
15
|
+
this.validator = new ISO8601TimeValidator();
|
|
19
16
|
this.getNow = ISO8601Time.getNow;
|
|
20
17
|
this.value = value ? value : this.getNow();
|
|
21
18
|
this.validateFormatOrThrow();
|
|
@@ -54,4 +51,3 @@ class ISO8601Time {
|
|
|
54
51
|
return `${hours}:${minutes}:${seconds}`;
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
|
-
exports.ISO8601Time = ISO8601Time;
|