ismx-nexo-node-app 0.4.4 → 0.4.6
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.
|
@@ -13,5 +13,22 @@ class DateUtils {
|
|
|
13
13
|
let hour = date.getHours().toString().padStart(2, '0');
|
|
14
14
|
return `${hour}:${mins}`;
|
|
15
15
|
}
|
|
16
|
+
static sum(date, value, component) {
|
|
17
|
+
let year = date.getFullYear();
|
|
18
|
+
let month = date.getMonth();
|
|
19
|
+
let day = date.getDate();
|
|
20
|
+
let hours = date.getHours();
|
|
21
|
+
let minutes = date.getMinutes();
|
|
22
|
+
let seconds = date.getSeconds();
|
|
23
|
+
let milliseconds = date.getMilliseconds();
|
|
24
|
+
return new Date(component === DateUtils.YEARS ? year + value : year, component === DateUtils.MONTHS ? month + value : month, component === DateUtils.DAYS ? day + value : day, component === DateUtils.HOURS ? hours + value : hours, component === DateUtils.MINUTES ? minutes + value : minutes, component === DateUtils.SECONDS ? seconds + value : seconds, component === DateUtils.MILLIS ? milliseconds + value : milliseconds);
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
exports.DateUtils = DateUtils;
|
|
28
|
+
DateUtils.MILLIS = 1;
|
|
29
|
+
DateUtils.SECONDS = 1000 * DateUtils.MILLIS;
|
|
30
|
+
DateUtils.MINUTES = 60 * DateUtils.SECONDS;
|
|
31
|
+
DateUtils.HOURS = 60 * DateUtils.MINUTES;
|
|
32
|
+
DateUtils.DAYS = 24 * DateUtils.HOURS;
|
|
33
|
+
DateUtils.MONTHS = 30 * DateUtils.DAYS;
|
|
34
|
+
DateUtils.YEARS = 365 * DateUtils.DAYS;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export declare abstract class DateUtils {
|
|
2
|
+
static readonly MILLIS: number;
|
|
3
|
+
static readonly SECONDS: number;
|
|
4
|
+
static readonly MINUTES: number;
|
|
5
|
+
static readonly HOURS: number;
|
|
6
|
+
static readonly DAYS: number;
|
|
7
|
+
static readonly MONTHS: number;
|
|
8
|
+
static readonly YEARS: number;
|
|
2
9
|
static getMonth(date: Date, using?: string[]): string;
|
|
3
10
|
static getDay(date: Date, using?: string[]): string;
|
|
4
11
|
static toTime(date: Date): string;
|
|
12
|
+
static sum(date: Date, value: number, component: number): Date;
|
|
5
13
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export abstract class DateUtils {
|
|
2
2
|
|
|
3
|
+
static readonly MILLIS: number = 1;
|
|
4
|
+
static readonly SECONDS: number = 1000 * DateUtils.MILLIS;
|
|
5
|
+
static readonly MINUTES: number = 60 * DateUtils.SECONDS;
|
|
6
|
+
static readonly HOURS: number = 60 * DateUtils.MINUTES;
|
|
7
|
+
static readonly DAYS: number = 24 * DateUtils.HOURS;
|
|
8
|
+
static readonly MONTHS: number = 30 * DateUtils.DAYS;
|
|
9
|
+
static readonly YEARS: number = 365 * DateUtils.DAYS;
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
static getMonth(date: Date, using: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dec']) {
|
|
4
13
|
return using[date.getMonth()]
|
|
5
14
|
}
|
|
@@ -14,4 +23,24 @@ export abstract class DateUtils {
|
|
|
14
23
|
return `${hour}:${mins}`;
|
|
15
24
|
}
|
|
16
25
|
|
|
26
|
+
static sum(date:Date, value:number, component: number) {
|
|
27
|
+
let year = date.getFullYear();
|
|
28
|
+
let month = date.getMonth();
|
|
29
|
+
let day = date.getDate();
|
|
30
|
+
let hours = date.getHours();
|
|
31
|
+
let minutes = date.getMinutes();
|
|
32
|
+
let seconds = date.getSeconds();
|
|
33
|
+
let milliseconds = date.getMilliseconds();
|
|
34
|
+
|
|
35
|
+
return new Date(
|
|
36
|
+
component === DateUtils.YEARS ? year+value : year,
|
|
37
|
+
component === DateUtils.MONTHS ? month+value : month,
|
|
38
|
+
component === DateUtils.DAYS ? day+value : day,
|
|
39
|
+
component === DateUtils.HOURS ? hours+value : hours,
|
|
40
|
+
component === DateUtils.MINUTES ? minutes+value : minutes,
|
|
41
|
+
component === DateUtils.SECONDS ? seconds+value : seconds,
|
|
42
|
+
component === DateUtils.MILLIS ? milliseconds+value : milliseconds
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
17
46
|
}
|