@juki-team/commons 0.1.32 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ export declare const changeYear: (date: Date, year: number) => Date;
2
+ export declare const changeMonth: (date: Date, monthIndex: number) => Date;
3
+ export declare const changeDay: (date: Date, day: number) => Date;
4
+ export declare const changeHours: (date: Date, hours: number) => Date;
5
+ export declare const changeMinutes: (date: Date, minutes: number) => Date;
6
+ export declare const changeSeconds: (date: Date, seconds: number) => Date;
7
+ export declare const changeMilliseconds: (date: Date, milliseconds: number) => Date;
8
+ export declare const decreaseYear: (date: Date, count?: number) => Date;
9
+ export declare const increaseYear: (date: Date, count?: number) => Date;
10
+ export declare const decreaseMonth: (date: Date) => Date;
11
+ export declare const increaseMonth: (date: Date) => Date;
12
+ export declare const decreaseDay: (date: Date) => Date;
13
+ export declare const increaseDay: (date: Date) => Date;
14
+ export declare const startOfDay: (date: Date) => Date;
15
+ export declare const endOfDay: (date: Date) => Date;
16
+ export declare const startOfMonth: (date: Date) => Date;
17
+ export declare const endOfMonth: (date: Date) => Date;
18
+ export declare const startOfYear: (date: Date) => Date;
19
+ export declare const endOfYear: (date: Date) => Date;
20
+ export declare const startOfWeek: (date: Date) => Date;
21
+ export declare const endOfWeek: (date: Date) => Date;
22
+ export declare const startOfHour: (date: Date) => Date;
23
+ export declare const endOfHour: (date: Date) => Date;
24
+ export declare const startOfMinute: (date: Date) => Date;
25
+ export declare const endOfMinute: (date: Date) => Date;
26
+ export declare const startOfSecond: (date: Date) => Date;
27
+ export declare const endOfSecond: (date: Date) => Date;
28
+ export declare const isEqual: (a: Date, b: Date) => boolean;
29
+ export declare const isSameYear: (a: Date, b: Date) => boolean;
30
+ export declare const isSameMonth: (a: Date, b: Date) => boolean;
31
+ export declare const isSameDay: (a: Date, b: Date) => boolean;
32
+ export declare const isSameHour: (a: Date, b: Date) => boolean;
33
+ export declare const isSameMinute: (a: Date, b: Date) => boolean;
34
+ export declare const isSameSecond: (a: Date, b: Date) => boolean;
35
+ export declare const isSameMillisecond: (a: Date, b: Date) => boolean;
36
+ export declare const isToday: (date: Date) => boolean;
37
+ export declare const isValidDate: (date: unknown) => date is Date;
38
+ export declare const isAfter: (a: Date, b: Date) => boolean;
39
+ export declare const isBefore: (a: Date, b: Date) => boolean;
40
+ export declare const isYearAfter: (a: Date, b: Date) => boolean;
41
+ export declare const isMonthAfter: (a: Date, b: Date) => boolean;
42
+ export declare const isDayAfter: (a: Date, b: Date) => boolean;
43
+ export declare const isHoursAfter: (a: Date, b: Date) => boolean;
44
+ export declare const isMinutesAfter: (a: Date, b: Date) => boolean;
45
+ export declare const isSecondsAfter: (a: Date, b: Date) => boolean;
46
+ export declare const isMillisecondsAfter: (a: Date, b: Date) => boolean;
47
+ export declare const isYearBefore: (a: Date, b: Date) => boolean;
48
+ export declare const isMonthBefore: (a: Date, b: Date) => boolean;
49
+ export declare const isDayBefore: (a: Date, b: Date) => boolean;
50
+ export declare const isHoursBefore: (a: Date, b: Date) => boolean;
51
+ export declare const isMinutesBefore: (a: Date, b: Date) => boolean;
52
+ export declare const isSecondsBefore: (a: Date, b: Date) => boolean;
53
+ export declare const isMillisecondsBefore: (a: Date, b: Date) => boolean;
54
+ export declare const isWithinInterval: (date: Date, { start, end }: {
55
+ start: Date;
56
+ end: Date;
57
+ }, cmp?: "[]" | "()" | "[)" | "(]") => boolean;
@@ -0,0 +1,157 @@
1
+ export const changeYear = (date, year) => {
2
+ const newDate = new Date(date);
3
+ newDate.setFullYear(year);
4
+ return newDate;
5
+ };
6
+ export const changeMonth = (date, monthIndex) => {
7
+ const newDate = new Date(date);
8
+ newDate.setMonth(monthIndex);
9
+ return newDate;
10
+ };
11
+ export const changeDay = (date, day) => {
12
+ const newDate = new Date(date);
13
+ newDate.setDate(day);
14
+ return newDate;
15
+ };
16
+ export const changeHours = (date, hours) => {
17
+ const newDate = new Date(date);
18
+ newDate.setHours(hours);
19
+ return newDate;
20
+ };
21
+ export const changeMinutes = (date, minutes) => {
22
+ const newDate = new Date(date);
23
+ newDate.setMinutes(minutes);
24
+ return newDate;
25
+ };
26
+ export const changeSeconds = (date, seconds) => {
27
+ const newDate = new Date(date);
28
+ newDate.setSeconds(seconds);
29
+ return newDate;
30
+ };
31
+ export const changeMilliseconds = (date, milliseconds) => {
32
+ const newDate = new Date(date);
33
+ newDate.setMilliseconds(milliseconds);
34
+ return newDate;
35
+ };
36
+ export const decreaseYear = (date, count = 1) => changeYear(date, date.getFullYear() - count);
37
+ export const increaseYear = (date, count = 1) => changeYear(date, date.getFullYear() + count);
38
+ export const decreaseMonth = (date) => {
39
+ const newDate = new Date(date);
40
+ newDate.setMonth(newDate.getMonth() - 1);
41
+ return newDate;
42
+ };
43
+ export const increaseMonth = (date) => {
44
+ const newDate = new Date(date);
45
+ newDate.setMonth(newDate.getMonth() + 1);
46
+ return newDate;
47
+ };
48
+ export const decreaseDay = (date) => {
49
+ const newDate = new Date(date);
50
+ newDate.setDate(newDate.getDate() - 1);
51
+ return newDate;
52
+ };
53
+ export const increaseDay = (date) => {
54
+ const newDate = new Date(date);
55
+ newDate.setDate(newDate.getDate() + 1);
56
+ return newDate;
57
+ };
58
+ export const startOfDay = (date) => {
59
+ const newDate = new Date(date);
60
+ newDate.setHours(0, 0, 0, 0);
61
+ return newDate;
62
+ };
63
+ export const endOfDay = (date) => {
64
+ const newDate = new Date(date);
65
+ newDate.setHours(23, 59, 59, 999);
66
+ return newDate;
67
+ };
68
+ export const startOfMonth = (date) => {
69
+ const newDate = new Date(date);
70
+ newDate.setDate(1);
71
+ return startOfDay(newDate);
72
+ };
73
+ export const endOfMonth = (date) => {
74
+ const nextMonth = startOfMonth(increaseMonth(date));
75
+ return new Date(nextMonth.getTime() - 1);
76
+ };
77
+ export const startOfYear = (date) => {
78
+ const newDate = new Date(date);
79
+ newDate.setMonth(0);
80
+ return startOfMonth(newDate);
81
+ };
82
+ export const endOfYear = (date) => {
83
+ const nextYear = startOfYear(increaseYear(date));
84
+ return new Date(nextYear.getTime() - 1);
85
+ };
86
+ export const startOfWeek = (date) => {
87
+ const newDate = new Date(date);
88
+ while (newDate.getDay()) {
89
+ newDate.setDate(newDate.getDate() - 1);
90
+ }
91
+ return startOfDay(newDate);
92
+ };
93
+ export const endOfWeek = (date) => {
94
+ const newDate = new Date(date);
95
+ while (newDate.getDay() < 6) {
96
+ newDate.setDate(newDate.getDate() + 1);
97
+ }
98
+ return endOfDay(newDate);
99
+ };
100
+ export const startOfHour = (date) => {
101
+ const newDate = new Date(date);
102
+ newDate.setMinutes(0, 0, 0);
103
+ return newDate;
104
+ };
105
+ export const endOfHour = (date) => {
106
+ const newDate = new Date(date);
107
+ newDate.setMinutes(59, 59, 999);
108
+ return newDate;
109
+ };
110
+ export const startOfMinute = (date) => {
111
+ const newDate = new Date(date);
112
+ newDate.setSeconds(0, 0);
113
+ return newDate;
114
+ };
115
+ export const endOfMinute = (date) => {
116
+ const newDate = new Date(date);
117
+ newDate.setSeconds(59, 999);
118
+ return newDate;
119
+ };
120
+ export const startOfSecond = (date) => {
121
+ const newDate = new Date(date);
122
+ newDate.setMilliseconds(0);
123
+ return newDate;
124
+ };
125
+ export const endOfSecond = (date) => {
126
+ const newDate = new Date(date);
127
+ newDate.setMilliseconds(999);
128
+ return newDate;
129
+ };
130
+ export const isEqual = (a, b) => a.getTime() === b.getTime();
131
+ export const isSameYear = (a, b) => a.getFullYear() === b.getFullYear();
132
+ export const isSameMonth = (a, b) => isSameYear(a, b) && a.getMonth() === b.getMonth();
133
+ export const isSameDay = (a, b) => isSameMonth(a, b) && a.getDate() === b.getDate();
134
+ export const isSameHour = (a, b) => isSameDay(a, b) && a.getHours() === b.getHours();
135
+ export const isSameMinute = (a, b) => isSameHour(a, b) && a.getMinutes() === b.getMinutes();
136
+ export const isSameSecond = (a, b) => isSameMinute(a, b) && a.getSeconds() === b.getSeconds();
137
+ export const isSameMillisecond = (a, b) => isEqual(a, b);
138
+ export const isToday = (date) => isSameDay(date, new Date());
139
+ export const isValidDate = (date) => date instanceof Date && !Number.isNaN(date.getTime());
140
+ export const isAfter = (a, b) => a.getTime() > b.getTime();
141
+ export const isBefore = (a, b) => a.getTime() < b.getTime();
142
+ export const isYearAfter = (a, b) => a.getFullYear() > b.getFullYear();
143
+ export const isMonthAfter = (a, b) => isYearAfter(a, b) || (isSameYear(a, b) && a.getMonth() > b.getMonth());
144
+ export const isDayAfter = (a, b) => isMonthAfter(a, b) || (isSameMonth(a, b) && a.getDate() > b.getDate());
145
+ export const isHoursAfter = (a, b) => isDayAfter(a, b) || (isSameDay(a, b) && a.getHours() > b.getHours());
146
+ export const isMinutesAfter = (a, b) => isHoursAfter(a, b) || (isSameHour(a, b) && a.getMinutes() > b.getMinutes());
147
+ export const isSecondsAfter = (a, b) => isMinutesAfter(a, b) || (isSameMinute(a, b) && a.getSeconds() > b.getSeconds());
148
+ export const isMillisecondsAfter = (a, b) => isSecondsAfter(a, b) || (isSameSecond(a, b) && a.getMilliseconds() > b.getMilliseconds());
149
+ export const isYearBefore = (a, b) => a.getFullYear() < b.getFullYear();
150
+ export const isMonthBefore = (a, b) => isYearBefore(a, b) || (isSameYear(a, b) && a.getMonth() < b.getMonth());
151
+ export const isDayBefore = (a, b) => isMonthBefore(a, b) || (isSameMonth(a, b) && a.getDate() < b.getDate());
152
+ export const isHoursBefore = (a, b) => isDayBefore(a, b) || (isSameDay(a, b) && a.getHours() < b.getHours());
153
+ export const isMinutesBefore = (a, b) => isHoursBefore(a, b) || (isSameHour(a, b) && a.getMinutes() < b.getMinutes());
154
+ export const isSecondsBefore = (a, b) => isMinutesBefore(a, b) || (isSameMinute(a, b) && a.getSeconds() < b.getSeconds());
155
+ export const isMillisecondsBefore = (a, b) => isSecondsBefore(a, b) || (isSameSecond(a, b) && a.getMilliseconds() < b.getMilliseconds());
156
+ export const isWithinInterval = (date, { start, end }, cmp = '[]') => (cmp.charAt(0) === '[' ? isEqual(date, start) || isAfter(date, start) : isAfter(date, start)) &&
157
+ (cmp.charAt(1) === ']' ? isEqual(date, end) || isBefore(date, end) : isBefore(date, end));
@@ -1,4 +1,4 @@
1
- import { JkError } from '../prototypes/index.js';
1
+ import { JkError } from '../errors/index.js';
2
2
  import { type ContentResponse, type ContentsMeta, type ContentsResponse, type ErrorResponse } from '../types/index.js';
3
3
  export declare function toJkError(err: unknown): JkError;
4
4
  export declare function errorsResponse(message: string, ...errors: JkError[]): ErrorResponse;
@@ -1,5 +1,5 @@
1
1
  import { getErrorMessage } from '../constants/index.js';
2
- import { JkError } from '../prototypes/index.js';
2
+ import { JkError } from '../errors/index.js';
3
3
  import { ErrorCode, } from '../types/index.js';
4
4
  import { consoleError, isStringJson } from './commons.js';
5
5
  export function toJkError(err) {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './constants/index.js';
2
+ export * from './date/index.js';
2
3
  export * from './dto/index.js';
4
+ export * from './errors/index.js';
3
5
  export * from './helpers/index.js';
6
+ export * from './number/index.js';
4
7
  export * from './prisma/enums/index.js';
5
- export * from './prototypes/index.js';
6
8
  export * from './types/index.js';
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './constants/index.js';
2
+ export * from './date/index.js';
2
3
  export * from './dto/index.js';
4
+ export * from './errors/index.js';
3
5
  export * from './helpers/index.js';
6
+ export * from './number/index.js';
4
7
  export * from './prisma/enums/index.js';
5
- export * from './prototypes/index.js';
6
8
  export * from './types/index.js';
@@ -0,0 +1,2 @@
1
+ export declare const padStart: (n: number, maxLength: number, fillString?: string) => string;
2
+ export declare const padEnd: (n: number, maxLength: number, fillString?: string) => string;
@@ -0,0 +1,2 @@
1
+ export const padStart = (n, maxLength, fillString = '0') => `${n}`.padStart(maxLength, fillString);
2
+ export const padEnd = (n, maxLength, fillString = '0') => `${n}`.padEnd(maxLength, fillString);
package/package.json CHANGED
@@ -1,21 +1,51 @@
1
1
  {
2
2
  "name": "@juki-team/commons",
3
- "version": "0.1.32",
3
+ "version": "0.2.0",
4
4
  "author": "juki-team",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
+ "sideEffects": false,
9
10
  "exports": {
10
11
  ".": {
11
12
  "types": "./dist/index.d.ts",
12
13
  "import": "./dist/index.js"
14
+ },
15
+ "./constants": {
16
+ "types": "./dist/constants/index.d.ts",
17
+ "import": "./dist/constants/index.js"
18
+ },
19
+ "./date": {
20
+ "types": "./dist/date/index.d.ts",
21
+ "import": "./dist/date/index.js"
22
+ },
23
+ "./dto": {
24
+ "types": "./dist/dto/index.d.ts",
25
+ "import": "./dist/dto/index.js"
26
+ },
27
+ "./errors": {
28
+ "types": "./dist/errors/index.d.ts",
29
+ "import": "./dist/errors/index.js"
30
+ },
31
+ "./helpers": {
32
+ "types": "./dist/helpers/index.d.ts",
33
+ "import": "./dist/helpers/index.js"
34
+ },
35
+ "./number": {
36
+ "types": "./dist/number/index.d.ts",
37
+ "import": "./dist/number/index.js"
38
+ },
39
+ "./prisma/enums": {
40
+ "types": "./dist/prisma/enums/index.d.ts",
41
+ "import": "./dist/prisma/enums/index.js"
42
+ },
43
+ "./types": {
44
+ "types": "./dist/types/index.d.ts",
45
+ "import": "./dist/types/index.js"
13
46
  }
14
47
  },
15
- "files": [
16
- "dist",
17
- "biome.shared.json"
18
- ],
48
+ "files": ["dist", "biome.shared.json"],
19
49
  "repository": "https://github.com/juki-team/commons.git",
20
50
  "publishConfig": {
21
51
  "access": "public",
@@ -1,62 +0,0 @@
1
- declare global {
2
- interface Date {
3
- changeYear(year: number): Date;
4
- changeMonth(monthIndex: number): Date;
5
- changeDay(date: number): Date;
6
- changeHours(hours: number): Date;
7
- changeMinutes(minutes: number): Date;
8
- changeSeconds(seconds: number): Date;
9
- changeMilliseconds(milliseconds: number): Date;
10
- decreaseYear(count?: number): Date;
11
- increaseYear(count?: number): Date;
12
- decreaseMonth(): Date;
13
- increaseMonth(): Date;
14
- decreaseDay(): Date;
15
- increaseDay(): Date;
16
- startOfYear(): Date;
17
- endOfYear(): Date;
18
- startOfMonth(): Date;
19
- endOfMonth(): Date;
20
- startOfWeek(): Date;
21
- endOfWeek(): Date;
22
- startOfDay(): Date;
23
- endOfDay(): Date;
24
- startOfHour(): Date;
25
- endOfHour(): Date;
26
- startOfMinute(): Date;
27
- endOfMinute(): Date;
28
- startOfSecond(): Date;
29
- endOfSecond(): Date;
30
- isSameYear(date: Date): boolean;
31
- isSameMonth(date: Date): boolean;
32
- isSameDay(date: Date): boolean;
33
- isSameHour(date: Date): boolean;
34
- isSameMinute(date: Date): boolean;
35
- isSameSecond(date: Date): boolean;
36
- isSameMillisecond(date: Date): boolean;
37
- isToday(): boolean;
38
- isEqual(date: Date): boolean;
39
- isValidDate(): boolean;
40
- isYearAfter(date: Date): boolean;
41
- isMonthAfter(date: Date): boolean;
42
- isDayAfter(date: Date): boolean;
43
- isHoursAfter(date: Date): boolean;
44
- isMinutesAfter(date: Date): boolean;
45
- isSecondsAfter(date: Date): boolean;
46
- isMillisecondsAfter(date: Date): boolean;
47
- isAfter(date: Date): boolean;
48
- isYearBefore(date: Date): boolean;
49
- isMonthBefore(date: Date): boolean;
50
- isDayBefore(date: Date): boolean;
51
- isHoursBefore(date: Date): boolean;
52
- isMinutesBefore(date: Date): boolean;
53
- isSecondsBefore(date: Date): boolean;
54
- isMillisecondsBefore(date: Date): boolean;
55
- isBefore(date: Date): boolean;
56
- isWithinInterval(props: {
57
- start: Date;
58
- end: Date;
59
- }, cmp?: '[]' | '()' | '[)' | '(]'): boolean;
60
- }
61
- }
62
- export {};
@@ -1,218 +0,0 @@
1
- /* eslint-disable no-extend-native */
2
- Date.prototype.changeYear = function (year) {
3
- const newDate = new Date(this);
4
- newDate.setFullYear(year);
5
- return newDate;
6
- };
7
- Date.prototype.changeMonth = function (monthIndex) {
8
- const newDate = new Date(this);
9
- newDate.setMonth(monthIndex);
10
- return newDate;
11
- };
12
- Date.prototype.changeDay = function (date) {
13
- const newDate = new Date(this);
14
- newDate.setDate(date);
15
- return newDate;
16
- };
17
- Date.prototype.changeHours = function (hours) {
18
- const newDate = new Date(this);
19
- newDate.setHours(hours);
20
- return newDate;
21
- };
22
- Date.prototype.changeMinutes = function (minutes) {
23
- const newDate = new Date(this);
24
- newDate.setMinutes(minutes);
25
- return newDate;
26
- };
27
- Date.prototype.changeSeconds = function (seconds) {
28
- const newDate = new Date(this);
29
- newDate.setSeconds(seconds);
30
- return newDate;
31
- };
32
- Date.prototype.changeMilliseconds = function (milliseconds) {
33
- const newDate = new Date(this);
34
- newDate.setMilliseconds(milliseconds);
35
- return newDate;
36
- };
37
- Date.prototype.decreaseYear = function (count = 1) {
38
- return this.changeYear(this.getFullYear() - count);
39
- };
40
- Date.prototype.increaseYear = function (count = 1) {
41
- return this.changeYear(this.getFullYear() + count);
42
- };
43
- Date.prototype.decreaseMonth = function () {
44
- const newDate = new Date(this);
45
- newDate.setMonth(newDate.getMonth() - 1);
46
- return newDate;
47
- };
48
- Date.prototype.increaseMonth = function () {
49
- const newDate = new Date(this);
50
- newDate.setMonth(newDate.getMonth() + 1);
51
- return newDate;
52
- };
53
- Date.prototype.increaseDay = function () {
54
- const newDate = new Date(this);
55
- newDate.setDate(newDate.getDate() + 1);
56
- return newDate;
57
- };
58
- Date.prototype.decreaseDay = function () {
59
- const newDate = new Date(this);
60
- newDate.setDate(newDate.getDate() - 1);
61
- return newDate;
62
- };
63
- Date.prototype.startOfYear = function () {
64
- const newDate = new Date(this);
65
- newDate.setMonth(0);
66
- return newDate.startOfMonth();
67
- };
68
- Date.prototype.endOfYear = function () {
69
- const nextMonth = this.increaseYear().startOfYear();
70
- return new Date(nextMonth.getTime() - 1);
71
- };
72
- Date.prototype.startOfMonth = function () {
73
- const newDate = new Date(this);
74
- newDate.setDate(1);
75
- return newDate.startOfDay();
76
- };
77
- Date.prototype.endOfMonth = function () {
78
- const nextMonth = this.increaseMonth().startOfMonth();
79
- return new Date(nextMonth.getTime() - 1);
80
- };
81
- Date.prototype.startOfWeek = function () {
82
- const newDate = new Date(this);
83
- while (newDate.getDay()) {
84
- newDate.setDate(newDate.getDate() - 1);
85
- }
86
- return newDate.startOfDay();
87
- };
88
- Date.prototype.endOfWeek = function () {
89
- const newDate = new Date(this);
90
- while (newDate.getDay() < 6) {
91
- newDate.setDate(newDate.getDate() - 1);
92
- }
93
- return newDate.endOfDay();
94
- };
95
- Date.prototype.startOfDay = function () {
96
- const newDate = new Date(this);
97
- newDate.setHours(0, 0, 0, 0);
98
- return newDate;
99
- };
100
- Date.prototype.endOfDay = function () {
101
- const newDate = new Date(this);
102
- newDate.setHours(23, 59, 59, 999);
103
- return newDate;
104
- };
105
- Date.prototype.startOfHour = function () {
106
- const newDate = new Date(this);
107
- newDate.setMinutes(0, 0, 0);
108
- return newDate;
109
- };
110
- Date.prototype.endOfHour = function () {
111
- const newDate = new Date(this);
112
- newDate.setMinutes(59, 59, 999);
113
- return newDate;
114
- };
115
- Date.prototype.startOfMinute = function () {
116
- const newDate = new Date(this);
117
- newDate.setSeconds(0, 0);
118
- return newDate;
119
- };
120
- Date.prototype.endOfMinute = function () {
121
- const newDate = new Date(this);
122
- newDate.setSeconds(59, 999);
123
- return newDate;
124
- };
125
- Date.prototype.startOfSecond = function () {
126
- const newDate = new Date(this);
127
- newDate.setMilliseconds(0);
128
- return newDate;
129
- };
130
- Date.prototype.endOfSecond = function () {
131
- const newDate = new Date(this);
132
- newDate.setMilliseconds(999);
133
- return newDate;
134
- };
135
- Date.prototype.isToday = function () {
136
- const today = new Date();
137
- return this.isSameDay(today);
138
- };
139
- Date.prototype.isEqual = function (date) {
140
- return this.getTime() === date.getTime();
141
- };
142
- Date.prototype.isSameYear = function (date) {
143
- return this.getFullYear() === date.getFullYear();
144
- };
145
- Date.prototype.isSameMonth = function (date) {
146
- return this.isSameYear(date) && this.getMonth() === date.getMonth();
147
- };
148
- Date.prototype.isSameDay = function (date) {
149
- return this.isSameMonth(date) && this.getDate() === date.getDate();
150
- };
151
- Date.prototype.isSameHour = function (date) {
152
- return this.isSameDay(date) && this.getHours() === date.getHours();
153
- };
154
- Date.prototype.isSameMinute = function (date) {
155
- return this.isSameHour(date) && this.getMinutes() === date.getMinutes();
156
- };
157
- Date.prototype.isSameSecond = function (date) {
158
- return this.isSameMinute(date) && this.getSeconds() === date.getSeconds();
159
- };
160
- Date.prototype.isSameMillisecond = function (date) {
161
- return this.isEqual(date);
162
- };
163
- Date.prototype.isValidDate = function () {
164
- return this instanceof Date && !Number.isNaN(this.getTime());
165
- };
166
- Date.prototype.isYearAfter = function (date) {
167
- return this.getFullYear() > date.getFullYear();
168
- };
169
- Date.prototype.isMonthAfter = function (date) {
170
- return this.isYearAfter(date) || (this.isSameYear(date) && this.getMonth() > date.getMonth());
171
- };
172
- Date.prototype.isDayAfter = function (date) {
173
- return this.isMonthAfter(date) || (this.isSameMonth(date) && this.getDate() > date.getDate());
174
- };
175
- Date.prototype.isHoursAfter = function (date) {
176
- return this.isDayAfter(date) || (this.isSameDay(date) && this.getHours() > date.getHours());
177
- };
178
- Date.prototype.isMinutesAfter = function (date) {
179
- return this.isHoursAfter(date) || (this.isSameHour(date) && this.getMinutes() > date.getMinutes());
180
- };
181
- Date.prototype.isSecondsAfter = function (date) {
182
- return this.isMinutesAfter(date) || (this.isSameMinute(date) && this.getSeconds() > date.getSeconds());
183
- };
184
- Date.prototype.isMillisecondsAfter = function (date) {
185
- return this.isSecondsAfter(date) || (this.isSameSecond(date) && this.getMilliseconds() > date.getMilliseconds());
186
- };
187
- Date.prototype.isAfter = function (date) {
188
- return this.getTime() > date.getTime();
189
- };
190
- Date.prototype.isYearBefore = function (date) {
191
- return this.getFullYear() < date.getFullYear();
192
- };
193
- Date.prototype.isMonthBefore = function (date) {
194
- return this.isYearBefore(date) || (this.isSameYear(date) && this.getMonth() < date.getMonth());
195
- };
196
- Date.prototype.isDayBefore = function (date) {
197
- return this.isMonthBefore(date) || (this.isSameMonth(date) && this.getDate() < date.getDate());
198
- };
199
- Date.prototype.isHoursBefore = function (date) {
200
- return this.isDayBefore(date) || (this.isSameDay(date) && this.getHours() < date.getHours());
201
- };
202
- Date.prototype.isMinutesBefore = function (date) {
203
- return this.isHoursBefore(date) || (this.isSameHour(date) && this.getMinutes() < date.getMinutes());
204
- };
205
- Date.prototype.isSecondsBefore = function (date) {
206
- return this.isMinutesBefore(date) || (this.isSameMinute(date) && this.getSeconds() < date.getSeconds());
207
- };
208
- Date.prototype.isMillisecondsBefore = function (date) {
209
- return this.isSecondsBefore(date) || (this.isSameSecond(date) && this.getMilliseconds() < date.getMilliseconds());
210
- };
211
- Date.prototype.isBefore = function (date) {
212
- return this.getTime() < date.getTime();
213
- };
214
- Date.prototype.isWithinInterval = function ({ start, end }, cmp = '[]') {
215
- return ((cmp.charAt(0) === '[' ? this.isEqual(start) || this.isAfter(start) : this.isAfter(start)) &&
216
- (cmp.charAt(1) === '[' ? this.isEqual(end) || this.isBefore(end) : this.isBefore(end)));
217
- };
218
- export {};
@@ -1,7 +0,0 @@
1
- declare global {
2
- interface Number {
3
- padStart(maxLength: number, fillString?: string): string;
4
- padEnd(maxLength: number, fillString?: string): string;
5
- }
6
- }
7
- export {};
@@ -1,8 +0,0 @@
1
- /* eslint-disable no-extend-native */
2
- Number.prototype.padStart = function (maxLength, fillString = '0') {
3
- return `${this}`.padStart(maxLength, fillString);
4
- };
5
- Number.prototype.padEnd = function (maxLength, fillString = '0') {
6
- return `${this}`.padEnd(maxLength, fillString);
7
- };
8
- export {};
@@ -1,3 +0,0 @@
1
- export * from './Date.js';
2
- export * from './Error.js';
3
- export * from './Number.js';
@@ -1,3 +0,0 @@
1
- export * from './Date.js';
2
- export * from './Error.js';
3
- export * from './Number.js';
File without changes