@sellout/utils 0.0.4 → 0.0.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.
- package/.dist/time.d.ts +11 -3
- package/.dist/time.js +20 -5
- package/.dist/time.js.map +1 -1
- package/package.json +4 -4
- package/src/time.ts +20 -6
package/.dist/time.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
export declare const SECOND =
|
|
1
|
+
export declare const SECOND = 1;
|
|
2
2
|
export declare const MINUTE: number;
|
|
3
3
|
export declare const HOUR: number;
|
|
4
4
|
export declare const DAY: number;
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
5
|
+
export declare const MILLISECONDS: {
|
|
6
|
+
SECOND: number;
|
|
7
|
+
MINUTE: number;
|
|
8
|
+
HOUR: number;
|
|
9
|
+
DAY: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function now(): number;
|
|
12
|
+
export declare function fromNow(seconds: any): number;
|
|
13
|
+
export declare function fromStartOfDay(seconds: number): number;
|
|
14
|
+
export declare const date: (seconds?: number | undefined) => Date;
|
|
7
15
|
export declare const fromDate: (millis: string | number) => number;
|
|
8
16
|
export declare const format: (secondsSinceEpoch: any, format?: string, timezone?: string) => any;
|
|
9
17
|
export declare const formatTimeOfDay: (secondsSinceEpoch: any, timezone?: string | undefined) => any;
|
package/.dist/time.js
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const moment = require("moment-timezone");
|
|
4
|
-
exports.SECOND =
|
|
4
|
+
exports.SECOND = 1;
|
|
5
5
|
exports.MINUTE = 60 * exports.SECOND;
|
|
6
6
|
exports.HOUR = 60 * exports.MINUTE;
|
|
7
7
|
exports.DAY = 24 * exports.HOUR;
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
exports.MILLISECONDS = {
|
|
9
|
+
SECOND: 1000,
|
|
10
|
+
MINUTE: this.SECOND * 60,
|
|
11
|
+
HOUR: this.MINUTE * 60,
|
|
12
|
+
DAY: this.HOUR * 24,
|
|
12
13
|
};
|
|
14
|
+
function now() {
|
|
15
|
+
return moment().unix();
|
|
16
|
+
}
|
|
17
|
+
exports.now = now;
|
|
18
|
+
;
|
|
19
|
+
function fromNow(seconds) {
|
|
20
|
+
return now() + seconds;
|
|
21
|
+
}
|
|
22
|
+
exports.fromNow = fromNow;
|
|
23
|
+
function fromStartOfDay(seconds) {
|
|
24
|
+
const startOfDay = moment().startOf("day").unix();
|
|
25
|
+
return Math.floor(startOfDay + seconds);
|
|
26
|
+
}
|
|
27
|
+
exports.fromStartOfDay = fromStartOfDay;
|
|
13
28
|
exports.date = function (seconds) {
|
|
14
29
|
if (!seconds)
|
|
15
30
|
return new Date();
|
package/.dist/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;AAAA,0CAA0C;AAE7B,QAAA,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;AAAA,0CAA0C;AAE7B,QAAA,MAAM,GAAG,CAAC,CAAC;AACX,QAAA,MAAM,GAAG,EAAE,GAAG,cAAM,CAAC;AACrB,QAAA,IAAI,GAAG,EAAE,GAAG,cAAM,CAAC;AACnB,QAAA,GAAG,GAAG,EAAE,GAAG,YAAI,CAAC;AAEhB,QAAA,YAAY,GAAG;IAC1B,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,EAAE;IACxB,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,EAAE;IACtB,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG,EAAE;CACpB,CAAC;AAEF,SAAgB,GAAG;IACjB,OAAO,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAF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 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sellout/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Sellout.io utils",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "npm run build",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"author": "samheutmaker@gmail.com",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sellout/models": "^0.0.
|
|
18
|
-
"@sellout/service": "^0.0.
|
|
17
|
+
"@sellout/models": "^0.0.6",
|
|
18
|
+
"@sellout/service": "^0.0.6",
|
|
19
19
|
"json2csv": "^5.0.0",
|
|
20
20
|
"moment-timezone": "^0.5.28",
|
|
21
21
|
"request": "^2.88.2",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"nodemon": "^2.0.2",
|
|
27
27
|
"typescript": "^3.8.3"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "293473fa4ad310e0ce454b24ba2670109bac0b4c"
|
|
30
30
|
}
|
package/src/time.ts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
import * as moment from 'moment-timezone';
|
|
2
2
|
|
|
3
|
-
export const SECOND =
|
|
3
|
+
export const SECOND = 1;
|
|
4
4
|
export const MINUTE = 60 * SECOND;
|
|
5
5
|
export const HOUR = 60 * MINUTE;
|
|
6
6
|
export const DAY = 24 * HOUR;
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export const MILLISECONDS = {
|
|
9
|
+
SECOND: 1000,
|
|
10
|
+
MINUTE: this.SECOND * 60,
|
|
11
|
+
HOUR: this.MINUTE * 60,
|
|
12
|
+
DAY: this.HOUR * 24,
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
+
export function now(): number {
|
|
16
|
+
return moment().unix();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function fromNow(seconds): number {
|
|
20
|
+
return now() + seconds;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function fromStartOfDay(seconds: number): number {
|
|
24
|
+
const startOfDay = moment().startOf("day").unix();
|
|
25
|
+
return Math.floor(startOfDay + seconds);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const date = function(seconds?: number): Date {
|
|
15
29
|
if(!seconds) return new Date();
|
|
16
30
|
const millis = seconds * 1000;
|
|
17
31
|
return new Date(millis);
|