@naturalcycles/js-lib 15.92.0 → 15.93.0

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.
@@ -31,10 +31,10 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
31
31
  * Supports 2 forms:
32
32
  * 1. 2023-03-03
33
33
  * 2. 2023-03-03T05:10:02
34
- * Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info,
35
- * but it will not take it into account.
34
+ * Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info.
35
+ * Millis (up to 3 digits after `.`) are taken into account, timezone info is not.
36
36
  */
37
- const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/;
37
+ const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?/;
38
38
  const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
39
39
  export class LocalTime {
40
40
  $date;
@@ -789,7 +789,10 @@ class LocalTimeFactory {
789
789
  };
790
790
  if (!this.isDateTimeObjectValid(o))
791
791
  return;
792
- return this.createDateFromDateTimeObject(o);
792
+ const d = this.createDateFromDateTimeObject(o);
793
+ if (m[7])
794
+ d.setMilliseconds(Number(m[7].padEnd(3, '0')));
795
+ return d;
793
796
  }
794
797
  parseLooselyOrUndefined(s) {
795
798
  if (!s || typeof s !== 'string')
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.92.0",
4
+ "version": "15.93.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2"
7
7
  },
@@ -69,10 +69,11 @@ const DATE_TIME_REGEX_LOOSE = /^(\d{4})-(\d{2})-(\d{2})([Tt\s](\d{2}):?(\d{2})?:
69
69
  * Supports 2 forms:
70
70
  * 1. 2023-03-03
71
71
  * 2. 2023-03-03T05:10:02
72
- * Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info,
73
- * but it will not take it into account.
72
+ * Ok, now it allows arbitrary stuff after `:ss`, to allow millis/timezone info.
73
+ * Millis (up to 3 digits after `.`) are taken into account, timezone info is not.
74
74
  */
75
- const DATE_TIME_REGEX_STRICT = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})/
75
+ const DATE_TIME_REGEX_STRICT =
76
+ /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?/
76
77
  const DATE_REGEX_STRICT = /^(\d\d\d\d)-(\d\d)-(\d\d)$/
77
78
 
78
79
  export class LocalTime {
@@ -924,7 +925,9 @@ class LocalTimeFactory {
924
925
  second: Number(m[6]) || 0,
925
926
  }
926
927
  if (!this.isDateTimeObjectValid(o)) return
927
- return this.createDateFromDateTimeObject(o)
928
+ const d = this.createDateFromDateTimeObject(o)
929
+ if (m[7]) d.setMilliseconds(Number(m[7].padEnd(3, '0')))
930
+ return d
928
931
  }
929
932
 
930
933
  private parseLooselyOrUndefined(s: string | undefined | null): Date | undefined {