@js-joda/core 4.3.1 → 5.0.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.
- package/CHANGELOG.md +5 -0
- package/dist/js-joda.esm.js +10099 -11486
- package/dist/js-joda.js +10099 -11486
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +2 -2
- package/src/format/DateTimeFormatterBuilder.js +2 -2
- package/src/temporal/Temporal.js +16 -0
- package/src/temporal/TemporalAmount.js +16 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@js-joda/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "a date and time library for javascript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"sourceMap": false,
|
|
49
49
|
"instrument": false
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "03943ccba7dab0178e3a112bce8a251410f89fe7"
|
|
52
52
|
}
|
|
@@ -1424,7 +1424,7 @@ class InstantPrinterParser {
|
|
|
1424
1424
|
if (hi > 0) {
|
|
1425
1425
|
buf.append('+').append(hi);
|
|
1426
1426
|
}
|
|
1427
|
-
buf.append(ldt);
|
|
1427
|
+
buf.append(ldt.toString());
|
|
1428
1428
|
if (ldt.second() === 0) {
|
|
1429
1429
|
buf.append(':00');
|
|
1430
1430
|
}
|
|
@@ -1435,7 +1435,7 @@ class InstantPrinterParser {
|
|
|
1435
1435
|
const lo = MathUtil.intMod(zeroSecs, SECONDS_PER_10000_YEARS);
|
|
1436
1436
|
const ldt = LocalDateTime.ofEpochSecond(lo - SECONDS_0000_TO_1970, 0, ZoneOffset.UTC);
|
|
1437
1437
|
const pos = buf.length();
|
|
1438
|
-
buf.append(ldt);
|
|
1438
|
+
buf.append(ldt.toString());
|
|
1439
1439
|
if (ldt.second() === 0) {
|
|
1440
1440
|
buf.append(':00');
|
|
1441
1441
|
}
|
package/src/temporal/Temporal.js
CHANGED
|
@@ -351,3 +351,19 @@ export class Temporal extends TemporalAccessor {
|
|
|
351
351
|
abstractMethodFail('_withField');
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
+
|
|
355
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive) {
|
|
356
|
+
Temporal.prototype[Symbol.toPrimitive] = function (hint) {
|
|
357
|
+
// hint could be 'number', 'string' or 'default'. Only 'number'
|
|
358
|
+
// should throw and 'default' is treated as 'string'.
|
|
359
|
+
if (hint !== 'number') {
|
|
360
|
+
return this.toString();
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
throw new TypeError(
|
|
364
|
+
'A conversion from Temporal to a number is not allowed. ' +
|
|
365
|
+
'To compare use the methods .equals(), .compareTo(), .isBefore() ' +
|
|
366
|
+
'or one that is more suitable to your use case.'
|
|
367
|
+
);
|
|
368
|
+
};
|
|
369
|
+
}
|
|
@@ -164,3 +164,19 @@ export class TemporalAmount {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
}
|
|
167
|
+
|
|
168
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive) {
|
|
169
|
+
TemporalAmount.prototype[Symbol.toPrimitive] = function (hint) {
|
|
170
|
+
// hint could be 'number', 'string' or 'default'. Only 'number'
|
|
171
|
+
// should throw and 'default' is treated as 'string'.
|
|
172
|
+
if (hint !== 'number') {
|
|
173
|
+
return this.toString();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
throw new TypeError(
|
|
177
|
+
'A conversion from TemporalAmount to a number is not allowed. ' +
|
|
178
|
+
'To compare use the methods .equals(), .compareTo(), .isBefore() ' +
|
|
179
|
+
'or one that is more suitable to your use case.'
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
}
|