@saihu/common 1.1.17 → 1.1.19
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/util/times.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export declare function getTomorrowDate(): string;
|
|
|
3
3
|
export declare function getCurrentChinaTime(): Date;
|
|
4
4
|
export declare function convertUtcToChinaTime(utcTimeString: string): string;
|
|
5
5
|
export declare function convertUtcToChinaTimeFormatted(utcTimeString: string, format?: string): string;
|
|
6
|
+
export declare const getNextVersion: () => string;
|
|
7
|
+
export declare const getCurrentVersion: () => string;
|
|
6
8
|
//# sourceMappingURL=times.d.ts.map
|
package/dist/util/times.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"times.d.ts","sourceRoot":"","sources":["../../src/util/times.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,mBAAmB,SAMlC;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,MAA8B,GACrC,MAAM,CAER"}
|
|
1
|
+
{"version":3,"file":"times.d.ts","sourceRoot":"","sources":["../../src/util/times.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,WAE7B;AAED,wBAAgB,eAAe,WAE9B;AAED,wBAAgB,mBAAmB,SAMlC;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,wBAAgB,8BAA8B,CAC5C,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,MAA8B,GACrC,MAAM,CAER;AAED,eAAO,MAAM,cAAc,QAAO,MAOjC,CAAC;AACF,eAAO,MAAM,iBAAiB,QAAO,MAOpC,CAAC"}
|
package/dist/util/times.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCurrentVersion = exports.getNextVersion = void 0;
|
|
6
7
|
exports.getCurrentDate = getCurrentDate;
|
|
7
8
|
exports.getTomorrowDate = getTomorrowDate;
|
|
8
9
|
exports.getCurrentChinaTime = getCurrentChinaTime;
|
|
@@ -15,10 +16,10 @@ const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
|
15
16
|
dayjs_1.default.extend(utc_1.default);
|
|
16
17
|
dayjs_1.default.extend(timezone_1.default);
|
|
17
18
|
function getCurrentDate() {
|
|
18
|
-
return (0, dayjs_1.default)().format('YYYY-MM-DD');
|
|
19
|
+
return (0, dayjs_1.default)().tz('Asia/Shanghai').format('YYYY-MM-DD');
|
|
19
20
|
}
|
|
20
21
|
function getTomorrowDate() {
|
|
21
|
-
return (0, dayjs_1.default)().add(1, 'day').format('YYYY-MM-DD');
|
|
22
|
+
return (0, dayjs_1.default)().tz('Asia/Shanghai').add(1, 'day').format('YYYY-MM-DD');
|
|
22
23
|
}
|
|
23
24
|
function getCurrentChinaTime() {
|
|
24
25
|
const chinaTime = (0, dayjs_1.default)().tz('Asia/Shanghai');
|
|
@@ -32,3 +33,21 @@ function convertUtcToChinaTime(utcTimeString) {
|
|
|
32
33
|
function convertUtcToChinaTimeFormatted(utcTimeString, format = 'YYYY-MM-DD HH:mm:ss') {
|
|
33
34
|
return dayjs_1.default.utc(utcTimeString).tz('Asia/Shanghai').format(format);
|
|
34
35
|
}
|
|
36
|
+
const getNextVersion = () => {
|
|
37
|
+
const currentUtcTime = (0, dayjs_1.default)().utc();
|
|
38
|
+
const cutoffTime = (0, dayjs_1.default)().utc().hour(3).minute(30).second(0);
|
|
39
|
+
const dateToUse = currentUtcTime.isAfter(cutoffTime)
|
|
40
|
+
? currentUtcTime.add(1, 'day')
|
|
41
|
+
: currentUtcTime;
|
|
42
|
+
return dateToUse.format('YYYYMMDD');
|
|
43
|
+
};
|
|
44
|
+
exports.getNextVersion = getNextVersion;
|
|
45
|
+
const getCurrentVersion = () => {
|
|
46
|
+
const currentUtcTime = (0, dayjs_1.default)().utc();
|
|
47
|
+
const cutoffTime = (0, dayjs_1.default)().utc().hour(3).minute(30).second(0);
|
|
48
|
+
const dateToUse = currentUtcTime.isAfter(cutoffTime)
|
|
49
|
+
? currentUtcTime
|
|
50
|
+
: currentUtcTime.subtract(1, 'day');
|
|
51
|
+
return dateToUse.format('YYYYMMDD');
|
|
52
|
+
};
|
|
53
|
+
exports.getCurrentVersion = getCurrentVersion;
|
package/package.json
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare class BaseResponseDto<T> {
|
|
2
|
-
code: number;
|
|
3
|
-
msg: string;
|
|
4
|
-
data: T | null;
|
|
5
|
-
constructor(code: number, msg: string, data?: T | null);
|
|
6
|
-
static success<T>(data: T): BaseResponseDto<T>;
|
|
7
|
-
static successWithMessage<T>(msg: string, data: T): BaseResponseDto<T>;
|
|
8
|
-
static error<T>(code: number, msg: string): BaseResponseDto<T>;
|
|
9
|
-
static readonly CODE_NOT_FOUND = 404;
|
|
10
|
-
static readonly CODE_UNAUTHORIZED = 401;
|
|
11
|
-
static readonly CODE_FORBIDDEN = 403;
|
|
12
|
-
static readonly CODE_BAD_REQUEST = 400;
|
|
13
|
-
static readonly CODE_SERVER_ERROR = 500;
|
|
14
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseResponseDto = void 0;
|
|
4
|
-
// src/dto/base-response.dto.ts
|
|
5
|
-
class BaseResponseDto {
|
|
6
|
-
constructor(code, msg, data = null) {
|
|
7
|
-
this.code = code;
|
|
8
|
-
this.msg = msg;
|
|
9
|
-
this.data = data;
|
|
10
|
-
}
|
|
11
|
-
static success(data) {
|
|
12
|
-
return new BaseResponseDto(0, 'success', data);
|
|
13
|
-
}
|
|
14
|
-
static successWithMessage(msg, data) {
|
|
15
|
-
return new BaseResponseDto(0, msg, data);
|
|
16
|
-
}
|
|
17
|
-
static error(code, msg) {
|
|
18
|
-
return new BaseResponseDto(code, msg, null);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.BaseResponseDto = BaseResponseDto;
|
|
22
|
-
// Common error codes
|
|
23
|
-
BaseResponseDto.CODE_NOT_FOUND = 404;
|
|
24
|
-
BaseResponseDto.CODE_UNAUTHORIZED = 401;
|
|
25
|
-
BaseResponseDto.CODE_FORBIDDEN = 403;
|
|
26
|
-
BaseResponseDto.CODE_BAD_REQUEST = 400;
|
|
27
|
-
BaseResponseDto.CODE_SERVER_ERROR = 500;
|