ismx-nexo-node-app 0.4.3 → 0.4.5

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,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DateUtils = void 0;
4
+ class DateUtils {
5
+ static getMonth(date, using = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dec']) {
6
+ return using[date.getMonth()];
7
+ }
8
+ static getDay(date, using = ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat']) {
9
+ return using[date.getDay()];
10
+ }
11
+ static toTime(date) {
12
+ let mins = date.getMinutes().toString().padStart(2, '0');
13
+ let hour = date.getHours().toString().padStart(2, '0');
14
+ return `${hour}:${mins}`;
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
+ 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
+ }
26
+ }
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;
@@ -0,0 +1,13 @@
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;
9
+ static getMonth(date: Date, using?: string[]): string;
10
+ static getDay(date: Date, using?: string[]): string;
11
+ static toTime(date: Date): string;
12
+ static sum(date: Date, value: number, component: number): void;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ismx-nexo-node-app",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "rm -rf ./dist && npx tsc",
@@ -0,0 +1,46 @@
1
+ export abstract class DateUtils {
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
+
12
+ static getMonth(date: Date, using: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dec']) {
13
+ return using[date.getMonth()]
14
+ }
15
+
16
+ static getDay(date: Date, using: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat']) {
17
+ return using[date.getDay()]
18
+ }
19
+
20
+ static toTime(date:Date) {
21
+ let mins = date.getMinutes().toString().padStart(2, '0');
22
+ let hour = date.getHours().toString().padStart(2, '0');
23
+ return `${hour}:${mins}`;
24
+ }
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
+ 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
+
46
+ }