dolphindb 3.0.105 → 3.0.107

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 CHANGED
@@ -339,9 +339,9 @@ export declare class DdbObj<TValue extends DdbValue = DdbValue> {
339
339
  data<TResult extends any[]>(this: DdbVectorObj, options?: ConvertOptions): TResult;
340
340
  data<TResult = any>(this: DdbObj, options?: ConvertOptions): TResult;
341
341
  /** 构建 Tensor
342
- @param buildParams 构建参数
343
- @param limit 限制每个维度最大元素个数(仅用于 log,不作他用)
344
- @returns */
342
+ @param buildParams 构建参数
343
+ @param limit 限制每个维度最大元素个数(仅用于 log,不作他用)
344
+ @returns */
345
345
  static parse_tensor(buildParams: {
346
346
  currentDim: number;
347
347
  dimensions: number;
@@ -505,7 +505,7 @@ export declare function second2str(second: number | null, format?: string): stri
505
505
  export declare function datetime2ms(datetime: number | null): number | null;
506
506
  export declare function datetime2str(datetime: number | null, format?: string): string;
507
507
  /** _datetime_formatter.format 会在 date 为 Invalid Date 时抛出错误 */
508
- export declare function timestamp2ms(timestamp: bigint | null): number | null;
508
+ export declare function timestamp2ms(timestamp: bigint | number | null): number | null;
509
509
  /** format timestamp (bigint) to string
510
510
  - timestamp: bigint value
511
511
  - format?:
package/browser.js CHANGED
@@ -1275,9 +1275,9 @@ export class DdbObj {
1275
1275
  }
1276
1276
  }
1277
1277
  /** 构建 Tensor
1278
- @param buildParams 构建参数
1279
- @param limit 限制每个维度最大元素个数(仅用于 log,不作他用)
1280
- @returns */
1278
+ @param buildParams 构建参数
1279
+ @param limit 限制每个维度最大元素个数(仅用于 log,不作他用)
1280
+ @returns */
1281
1281
  static parse_tensor(buildParams, limit = -1) {
1282
1282
  const { currentDim, dimensions, rawData, le, dataByte, dataType, shape, strides } = buildParams;
1283
1283
  const tensor = [];
@@ -2435,13 +2435,13 @@ export class DdbTable extends DdbObj {
2435
2435
  }
2436
2436
  }
2437
2437
  export function date2ms(date) {
2438
- // 将 server 的本地时间 (以 ms 为单位,1970.01.01 00:00:00 作为零点) 当成是客户端这里的本地的时间,然后根据本地的时区信息转换为 utc 时间
2439
- // 本地的时区与实际的时间值相关,timezone offset 可能会受到夏令时 (DST) 的影响
2438
+ // 将 server 的本地时间 (以 ms 为单位,1970.01.01 00:00:00 作为零点) 作为 UTC-0 格式化为字符串,然后根据本地的时区解析这个字符串转换为 UTC-8
2439
+ // 本地的时区与实际的时间值相关,getTimezoneOffset() 可能会受到夏令时 (DST) 的影响,不能使用
2440
2440
  // 得到的 utc 毫秒数交给 js date 或者 dayjs 去格式化
2441
2441
  if (date === null || date === nulls.int32)
2442
2442
  return null;
2443
2443
  const ms = 1000 * 3600 * 24 * date;
2444
- return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
2444
+ return timestamp2ms(ms);
2445
2445
  }
2446
2446
  export function date2str(date, format = 'YYYY.MM.DD') {
2447
2447
  return (date === null || date === nulls.int32) ?
@@ -2468,7 +2468,7 @@ export function time2ms(time) {
2468
2468
  return (time === null || time === nulls.int32) ?
2469
2469
  null
2470
2470
  :
2471
- 1000 * 60 * new Date(time).getTimezoneOffset() + time;
2471
+ timestamp2ms(time);
2472
2472
  }
2473
2473
  export function time2str(time, format = 'HH:mm:ss.SSS') {
2474
2474
  return (time === null || time === nulls.int32) ?
@@ -2480,7 +2480,7 @@ export function minute2ms(minute) {
2480
2480
  if (minute === null || minute === nulls.int32)
2481
2481
  return null;
2482
2482
  const ms = 60 * 1000 * minute;
2483
- return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
2483
+ return timestamp2ms(ms);
2484
2484
  }
2485
2485
  export function minute2str(minute, format = 'HH:mm[m]') {
2486
2486
  return (minute === null || minute === nulls.int32) ?
@@ -2492,7 +2492,7 @@ export function second2ms(second) {
2492
2492
  if (second === null || second === nulls.int32)
2493
2493
  return null;
2494
2494
  const ms = 1000 * second;
2495
- return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
2495
+ return timestamp2ms(ms);
2496
2496
  }
2497
2497
  export function second2str(second, format = 'HH:mm:ss') {
2498
2498
  return (second === null || second === nulls.int32) ?
@@ -2534,13 +2534,13 @@ export function datehour2ms(datehour) {
2534
2534
  if (datehour === null || datehour === nulls.int32)
2535
2535
  return null;
2536
2536
  const ms = 1000 * 3600 * datehour;
2537
- return 1000 * 60 * new Date(ms).getTimezoneOffset() + ms;
2537
+ return timestamp2ms(ms);
2538
2538
  }
2539
2539
  export function datehour2str(datehour, format = 'YYYY.MM.DDTHH') {
2540
2540
  if (datehour === null || datehour === nulls.int32)
2541
2541
  return 'null';
2542
2542
  const ms = 1000 * 3600 * datehour;
2543
- return dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format);
2543
+ return dayjs(timestamp2ms(ms)).format(format);
2544
2544
  }
2545
2545
  /** parse timestamp string to bigint value
2546
2546
  - str: timestamp string, 如果为空字符串或 'null' 会返回对应的空值 (nulls.int64)
@@ -2571,7 +2571,7 @@ export function nanotime2str(nanotime, format = 'HH:mm:ss.SSSSSSSSS') {
2571
2571
  const i_nanosecond_start = format.indexOf('SSSSSSSSS', i_second_end);
2572
2572
  assert(i_nanosecond_start !== -1, t('格式串必须包含纳秒的格式 (SSSSSSSSS)'));
2573
2573
  const ms = Number(nanotime) / 1000000;
2574
- return (dayjs(1000 * 60 * new Date(ms).getTimezoneOffset() + ms).format(format.slice(0, i_second_end)) +
2574
+ return (dayjs(timestamp2ms(ms)).format(format.slice(0, i_second_end)) +
2575
2575
  format.slice(i_second_end, i_nanosecond_start) +
2576
2576
  String(nanotime % 1000000000n).padStart(9, '0'));
2577
2577
  }
@@ -2996,12 +2996,12 @@ export class DDB {
2996
2996
  if (this.error)
2997
2997
  throw this.error;
2998
2998
  const args = DdbObj.to_ddbobjs(_args);
2999
- const rpc_id = ` (id = ${id})`;
2999
+ const rpc_id = `(id = ${id})`;
3000
3000
  const command = this.enc.encode((() => {
3001
3001
  switch (type) {
3002
3002
  case 'function':
3003
3003
  if (this.verbose)
3004
- console.log(func + args.map(arg => arg.toString()).join(', ').bracket() + rpc_id);
3004
+ console.log(func, args.map(arg => arg.data()), rpc_id);
3005
3005
  assert(!func.includes('\0'), t('发送至 DolphinDB 执行的脚本中间不能含有 \\0'));
3006
3006
  return 'function\n' +
3007
3007
  `${func}\n` +
@@ -3009,14 +3009,15 @@ export class DDB {
3009
3009
  `${Number(DDB.le_client)}\n`;
3010
3010
  case 'script':
3011
3011
  if (this.verbose)
3012
- console.log(script + rpc_id);
3012
+ console.log(script, rpc_id);
3013
3013
  assert(!script.includes('\0'), t('发送至 DolphinDB 执行的脚本中间不能含有 \\0'));
3014
3014
  return 'script\n' +
3015
3015
  script;
3016
3016
  case 'variable':
3017
3017
  if (this.verbose)
3018
- for (let i = 0; i < vars.length; i++)
3019
- console.log(`${vars[i]} = ${args[i].toString()}`);
3018
+ vars.forEach((v, i) => {
3019
+ console.log(v, '=', args[i].data());
3020
+ });
3020
3021
  return 'variable\n' +
3021
3022
  `${vars.join(',')}\n` +
3022
3023
  `${vars.length}\n` +
@@ -3029,7 +3030,7 @@ export class DDB {
3029
3030
  `login(${this.username.quote()}, ${this.password.quote()})`
3030
3031
  :
3031
3032
  '') +
3032
- rpc_id);
3033
+ ` ${rpc_id}`);
3033
3034
  return 'connect\n' +
3034
3035
  // 详见 InterProcessIO.cpp#APISocketConsole::parseScript 中的
3035
3036
  // Util::startWith "connect"
@@ -3087,7 +3088,7 @@ export class DDB {
3087
3088
  ]));
3088
3089
  });
3089
3090
  if (this.verbose)
3090
- console.log(result.toString() + rpc_id);
3091
+ console.log(result.data(), rpc_id);
3091
3092
  return result;
3092
3093
  });
3093
3094
  }