dolphindb 0.0.14 → 0.0.15
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/browser.d.ts +25 -3
- package/browser.js +60 -15
- package/browser.js.map +1 -1
- package/index.d.ts +25 -3
- package/index.js +60 -15
- package/index.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -195,11 +195,33 @@ export declare class DdbFunction extends DdbObj<DdbFunctionDefValue> {
|
|
|
195
195
|
}
|
|
196
196
|
export declare function date2str(date: number, format?: string): string;
|
|
197
197
|
export declare function datetime2str(datetime: number, format?: string): string;
|
|
198
|
-
|
|
198
|
+
/** format timestamp (bigint) to string
|
|
199
|
+
- timestamp: bigint value
|
|
200
|
+
- format?:
|
|
201
|
+
format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
|
|
202
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
203
|
+
*/
|
|
204
|
+
export declare function timestamp2str(timestamp: bigint, format?: string): string;
|
|
205
|
+
/** parse timestamp string to bigint value
|
|
206
|
+
- str: timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
|
|
207
|
+
- format?:
|
|
208
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
209
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
210
|
+
*/
|
|
211
|
+
export declare function str2timestamp(str: string, format?: string): bigint;
|
|
212
|
+
/** format nanotimestamp value (bigint) to string
|
|
213
|
+
- nanotimestamp: bigint value
|
|
214
|
+
- format?:
|
|
215
|
+
format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
216
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
|
|
217
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
218
|
+
*/
|
|
199
219
|
export declare function nanotimestamp2str(nanotimestamp: bigint, format?: string): string;
|
|
200
220
|
/** parse nano timestamp string to bigint value
|
|
201
|
-
- str: nano timestamp string,
|
|
202
|
-
- format?:
|
|
221
|
+
- str: nano timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
|
|
222
|
+
- format?:
|
|
223
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
224
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
|
|
203
225
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
204
226
|
*/
|
|
205
227
|
export declare function str2nanotimestamp(str: string, format?: string): bigint;
|
package/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbFunction = exports.DdbPair = exports.DdbVectorAny = exports.DdbVectorDouble = exports.DdbVectorString = exports.DdbVectorInt = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
3
|
+
exports.ddb = exports.DDB = exports.str2nanotimestamp = exports.nanotimestamp2str = exports.str2timestamp = exports.timestamp2str = exports.datetime2str = exports.date2str = exports.DdbFunction = exports.DdbPair = exports.DdbVectorAny = exports.DdbVectorDouble = exports.DdbVectorString = exports.DdbVectorInt = exports.DdbNanoTimeStamp = exports.DdbTimeStamp = exports.DdbDateTime = exports.DdbDouble = exports.DdbLong = exports.DdbString = exports.DdbInt = exports.DdbChar = exports.DdbBool = exports.DdbVoid = exports.DdbObj = exports.timezone_offset = exports.nulls = exports.DdbFunctionType = exports.DdbType = exports.DdbForm = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
6
|
const customParseFormat_js_1 = tslib_1.__importDefault(require("dayjs/plugin/customParseFormat.js"));
|
|
@@ -1076,34 +1076,79 @@ function datetime2str(datetime, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
|
1076
1076
|
(0, dayjs_1.default)(exports.timezone_offset + 1000 * datetime).format(format);
|
|
1077
1077
|
}
|
|
1078
1078
|
exports.datetime2str = datetime2str;
|
|
1079
|
-
|
|
1079
|
+
/** format timestamp (bigint) to string
|
|
1080
|
+
- timestamp: bigint value
|
|
1081
|
+
- format?:
|
|
1082
|
+
format string, default to `YYYY.MM.DD HH:mm:ss.SSS`
|
|
1083
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1084
|
+
*/
|
|
1085
|
+
function timestamp2str(timestamp, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
1080
1086
|
return timestamp === exports.nulls.int64 ?
|
|
1081
1087
|
''
|
|
1082
1088
|
:
|
|
1083
|
-
(0, dayjs_1.default)(exports.timezone_offset + Number(timestamp)).format(
|
|
1089
|
+
(0, dayjs_1.default)(exports.timezone_offset + Number(timestamp)).format(format);
|
|
1084
1090
|
}
|
|
1085
1091
|
exports.timestamp2str = timestamp2str;
|
|
1086
|
-
|
|
1087
|
-
return
|
|
1088
|
-
|
|
1089
|
-
:
|
|
1090
|
-
|
|
1092
|
+
/** parse timestamp string to bigint value
|
|
1093
|
+
- str: timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
|
|
1094
|
+
- format?:
|
|
1095
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSS`
|
|
1096
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1097
|
+
*/
|
|
1098
|
+
function str2timestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSS') {
|
|
1099
|
+
if (!str)
|
|
1100
|
+
return exports.nulls.int64;
|
|
1101
|
+
if (str.length !== format.length)
|
|
1102
|
+
throw new Error('The length of the timestamp string is not equal to the length of the format string');
|
|
1103
|
+
return BigInt(-exports.timezone_offset +
|
|
1104
|
+
(0, dayjs_1.default)(str, format).valueOf());
|
|
1105
|
+
}
|
|
1106
|
+
exports.str2timestamp = str2timestamp;
|
|
1107
|
+
/** format nanotimestamp value (bigint) to string
|
|
1108
|
+
- nanotimestamp: bigint value
|
|
1109
|
+
- format?:
|
|
1110
|
+
format string, default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
1111
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
|
|
1112
|
+
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1113
|
+
*/
|
|
1114
|
+
function nanotimestamp2str(nanotimestamp, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
1115
|
+
if (nanotimestamp === exports.nulls.int64)
|
|
1116
|
+
return '';
|
|
1117
|
+
const i_second_start = format.indexOf('ss');
|
|
1118
|
+
if (i_second_start === -1)
|
|
1119
|
+
throw new Error('The format string must contain the format for seconds (ss)');
|
|
1120
|
+
const i_second_end = i_second_start + 2;
|
|
1121
|
+
const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
|
|
1122
|
+
if (i_nanosecond_start === -1)
|
|
1123
|
+
throw new Error('The format string must contain the format for nanoseconds (SSSSSSSSS)');
|
|
1124
|
+
return ((0, dayjs_1.default)(exports.timezone_offset + (Number(nanotimestamp) / 1000000)).format(format.slice(0, i_second_end)) +
|
|
1125
|
+
format.slice(i_second_end, i_nanosecond_start) +
|
|
1126
|
+
String(nanotimestamp % 1000000000n));
|
|
1091
1127
|
}
|
|
1092
1128
|
exports.nanotimestamp2str = nanotimestamp2str;
|
|
1093
1129
|
/** parse nano timestamp string to bigint value
|
|
1094
|
-
- str: nano timestamp string,
|
|
1095
|
-
- format?:
|
|
1130
|
+
- str: nano timestamp string, If it is an empty string, it will return the corresponding empty value (nulls.int64)
|
|
1131
|
+
- format?:
|
|
1132
|
+
The format string corresponding to the incoming string, the default is `YYYY.MM.DD HH:mm:ss.SSSSSSSSS`
|
|
1133
|
+
Seconds are in the format ss (must be included); nanoseconds are in the format SSSSSSSSS (must be included)
|
|
1096
1134
|
https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens
|
|
1097
1135
|
*/
|
|
1098
|
-
function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss') {
|
|
1136
|
+
function str2nanotimestamp(str, format = 'YYYY.MM.DD HH:mm:ss.SSSSSSSSS') {
|
|
1099
1137
|
if (!str)
|
|
1100
1138
|
return exports.nulls.int64;
|
|
1101
|
-
if (str.length
|
|
1102
|
-
throw new Error('nanotimestamp
|
|
1139
|
+
if (str.length !== format.length)
|
|
1140
|
+
throw new Error('nanotimestamp string length is not equal to format string length');
|
|
1141
|
+
const i_second_start = format.indexOf('ss');
|
|
1142
|
+
if (i_second_start === -1)
|
|
1143
|
+
throw new Error('The format string must contain the format for seconds (ss)');
|
|
1144
|
+
const i_second_end = i_second_start + 2;
|
|
1145
|
+
const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
|
|
1146
|
+
if (i_nanosecond_start === -1)
|
|
1147
|
+
throw new Error('Format string must contain nanosecond format (SSSSSSSSS)');
|
|
1103
1148
|
return (BigInt(-exports.timezone_offset +
|
|
1104
|
-
(0, dayjs_1.default)(str.slice(0, format.
|
|
1149
|
+
(0, dayjs_1.default)(str.slice(0, i_second_end), format.slice(0, i_second_end)).valueOf()) * 1000000n
|
|
1105
1150
|
+
|
|
1106
|
-
BigInt(str.slice(
|
|
1151
|
+
BigInt(str.slice(i_nanosecond_start, i_nanosecond_start + 9)));
|
|
1107
1152
|
}
|
|
1108
1153
|
exports.str2nanotimestamp = str2nanotimestamp;
|
|
1109
1154
|
class DDB {
|