@js-joda/core 6.2.0 → 6.3.1
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/js-joda.cjs.js +5360 -5089
- package/dist/js-joda.cjs.js.map +1 -1
- package/dist/js-joda.esm.js +5360 -5089
- package/dist/js-joda.esm.js.map +1 -1
- package/dist/js-joda.js +5360 -5089
- package/dist/js-joda.js.map +1 -1
- package/dist/js-joda.min.js +2 -2
- package/package.json +2 -2
- package/src/Duration.js +128 -6
- package/src/Instant.js +6 -0
- package/src/LocalDate.js +2 -1
- package/src/MonthDay.js +1 -1
- package/src/ZonedDateTime.js +1 -1
- package/src/format/DateTimeBuilder.js +184 -39
- package/src/format/EnumMap.js +94 -24
- package/src/temporal/TemporalField.js +1 -1
- package/src/zone/SystemDefaultZoneRules.js +27 -4
- package/src/zone/ZoneOffsetTransition.js +2 -2
- package/typings/js-joda.d.ts +15 -0
- package/typings/js-joda.flow.js +5 -0
|
@@ -199,7 +199,7 @@ export class TemporalField {
|
|
|
199
199
|
* Checks if this field is supported by the temporal object.
|
|
200
200
|
*
|
|
201
201
|
* This determines whether the temporal accessor supports this field.
|
|
202
|
-
* If this returns false, the
|
|
202
|
+
* If this returns false, the temporal cannot be queried for this field.
|
|
203
203
|
*
|
|
204
204
|
* There are two equivalent ways of using this method.
|
|
205
205
|
* The first is to invoke this method directly.
|
|
@@ -7,6 +7,29 @@ import { ZoneRules } from './ZoneRules';
|
|
|
7
7
|
import { ZoneOffset } from '../ZoneOffset';
|
|
8
8
|
import { DateTimeException } from '../errors';
|
|
9
9
|
|
|
10
|
+
// the range of a Date in epoch millis (ECMA-262), a Date outside of it is invalid
|
|
11
|
+
const MAX_DATE_EPOCH_MILLI = 8640000000000000;
|
|
12
|
+
|
|
13
|
+
// the timezone offset of a Date in minutes, as Date.getTimezoneOffset(); an epoch milli outside
|
|
14
|
+
// the range of a Date is clamped to it, so that far instants get the offset at the end of the range
|
|
15
|
+
function timezoneOffsetInMinutes(epochMilli) {
|
|
16
|
+
const clamped = Math.max(-MAX_DATE_EPOCH_MILLI, Math.min(MAX_DATE_EPOCH_MILLI, epochMilli));
|
|
17
|
+
return new Date(clamped).getTimezoneOffset();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// the epoch milli of the instant, clamped to the range of a Date; Instant.toEpochMilli() would
|
|
21
|
+
// overflow for instants like Instant.MAX
|
|
22
|
+
function clampedEpochMilli(instant) {
|
|
23
|
+
const epochSecond = instant.epochSecond();
|
|
24
|
+
if (epochSecond > MAX_DATE_EPOCH_MILLI / 1000) {
|
|
25
|
+
return MAX_DATE_EPOCH_MILLI;
|
|
26
|
+
}
|
|
27
|
+
if (epochSecond < -MAX_DATE_EPOCH_MILLI / 1000) {
|
|
28
|
+
return -MAX_DATE_EPOCH_MILLI;
|
|
29
|
+
}
|
|
30
|
+
return instant.toEpochMilli();
|
|
31
|
+
}
|
|
32
|
+
|
|
10
33
|
export class SystemDefaultZoneRules extends ZoneRules {
|
|
11
34
|
|
|
12
35
|
isFixedOffset(){
|
|
@@ -19,7 +42,7 @@ export class SystemDefaultZoneRules extends ZoneRules {
|
|
|
19
42
|
* @returns {ZoneOffset}
|
|
20
43
|
*/
|
|
21
44
|
offsetOfInstant(instant){
|
|
22
|
-
const offsetInMinutes =
|
|
45
|
+
const offsetInMinutes = timezoneOffsetInMinutes(clampedEpochMilli(instant));
|
|
23
46
|
return ZoneOffset.ofTotalMinutes(offsetInMinutes * -1);
|
|
24
47
|
}
|
|
25
48
|
|
|
@@ -29,7 +52,7 @@ export class SystemDefaultZoneRules extends ZoneRules {
|
|
|
29
52
|
* @returns {ZoneOffset}
|
|
30
53
|
*/
|
|
31
54
|
offsetOfEpochMilli(epochMilli){
|
|
32
|
-
const offsetInMinutes =
|
|
55
|
+
const offsetInMinutes = timezoneOffsetInMinutes(epochMilli);
|
|
33
56
|
return ZoneOffset.ofTotalMinutes(offsetInMinutes * -1);
|
|
34
57
|
}
|
|
35
58
|
|
|
@@ -48,9 +71,9 @@ export class SystemDefaultZoneRules extends ZoneRules {
|
|
|
48
71
|
*/
|
|
49
72
|
offsetOfLocalDateTime(localDateTime){
|
|
50
73
|
const epochMilli = localDateTime.toEpochSecond(ZoneOffset.UTC) * 1000;
|
|
51
|
-
const offsetInMinutesBeforePossibleTransition =
|
|
74
|
+
const offsetInMinutesBeforePossibleTransition = timezoneOffsetInMinutes(epochMilli);
|
|
52
75
|
const epochMilliSystemZone = epochMilli + offsetInMinutesBeforePossibleTransition * 60000;
|
|
53
|
-
const offsetInMinutesAfterPossibleTransition =
|
|
76
|
+
const offsetInMinutesAfterPossibleTransition = timezoneOffsetInMinutes(epochMilliSystemZone);
|
|
54
77
|
return ZoneOffset.ofTotalMinutes(offsetInMinutesAfterPossibleTransition * -1);
|
|
55
78
|
}
|
|
56
79
|
|
|
@@ -17,7 +17,7 @@ import { LocalDateTime } from '../LocalDateTime';
|
|
|
17
17
|
* The discontinuity is normally a gap in spring and an overlap in autumn.
|
|
18
18
|
* {@link ZoneOffsetTransition} models the transition between the two offsets.
|
|
19
19
|
*
|
|
20
|
-
* Gaps occur where there are local date-times that simply do not
|
|
20
|
+
* Gaps occur where there are local date-times that simply do not exist.
|
|
21
21
|
* An example would be when the offset changes from `+03:00` to `+04:00`.
|
|
22
22
|
* This might be described as 'the clocks will move forward one hour tonight at 1am'.
|
|
23
23
|
*
|
|
@@ -178,7 +178,7 @@ export class ZoneOffsetTransition {
|
|
|
178
178
|
/**
|
|
179
179
|
* Does this transition represent a gap in the local time-line.
|
|
180
180
|
*
|
|
181
|
-
* Gaps occur where there are local date-times that simply do not
|
|
181
|
+
* Gaps occur where there are local date-times that simply do not exist.
|
|
182
182
|
* An example would be when the offset changes from `+01:00` to `+02:00`.
|
|
183
183
|
* This might be described as 'the clocks will move forward one hour tonight at 1am'.
|
|
184
184
|
*
|
package/typings/js-joda.d.ts
CHANGED
|
@@ -1110,6 +1110,7 @@ export class Duration extends TemporalAmount {
|
|
|
1110
1110
|
minus(amount: number, unit: TemporalUnit): Duration;
|
|
1111
1111
|
minus(duration: Duration): Duration;
|
|
1112
1112
|
minusDays(daysToSubtract: number): Duration;
|
|
1113
|
+
minusDuration(duration: Duration): Duration;
|
|
1113
1114
|
minusHours(hoursToSubtract: number): Duration;
|
|
1114
1115
|
minusMillis(millisToSubtract: number): Duration;
|
|
1115
1116
|
minusMinutes(minutesToSubtract: number): Duration;
|
|
@@ -1136,10 +1137,12 @@ export class Duration extends TemporalAmount {
|
|
|
1136
1137
|
toMillis(): number;
|
|
1137
1138
|
toMinutes(): number;
|
|
1138
1139
|
toNanos(): number;
|
|
1140
|
+
toDaysPart(): number;
|
|
1139
1141
|
toHoursPart(): number;
|
|
1140
1142
|
toMinutesPart(): number;
|
|
1141
1143
|
toSecondsPart(): number;
|
|
1142
1144
|
toMillisPart(): number;
|
|
1145
|
+
toNanosPart(): number;
|
|
1143
1146
|
toString(): string;
|
|
1144
1147
|
units(): TemporalUnit[];
|
|
1145
1148
|
withNanos(nanoOfSecond: number): Duration;
|
|
@@ -1534,6 +1537,7 @@ export class Year extends Temporal implements TemporalAdjuster {
|
|
|
1534
1537
|
atMonthDay(monthDay: MonthDay): LocalDate;
|
|
1535
1538
|
compareTo(other: Year): number;
|
|
1536
1539
|
equals(other: any): boolean;
|
|
1540
|
+
format(formatter: DateTimeFormatter): string;
|
|
1537
1541
|
getLong(field: TemporalField): number;
|
|
1538
1542
|
isAfter(other: Year): boolean;
|
|
1539
1543
|
isBefore(other: Year): boolean;
|
|
@@ -1700,6 +1704,7 @@ export class OffsetDateTime extends Temporal implements TemporalAdjuster {
|
|
|
1700
1704
|
toLocalTime(): LocalTime;
|
|
1701
1705
|
toOffsetTime(): OffsetTime;
|
|
1702
1706
|
toString(): string;
|
|
1707
|
+
toZonedDateTime(): ZonedDateTime;
|
|
1703
1708
|
truncatedTo(unit: TemporalUnit): OffsetDateTime;
|
|
1704
1709
|
until(endExclusive: Temporal, unit: TemporalUnit): number;
|
|
1705
1710
|
with(adjuster: TemporalAdjuster): OffsetDateTime;
|
|
@@ -2069,6 +2074,7 @@ export class ZoneOffset extends ZoneId implements TemporalAdjuster {
|
|
|
2069
2074
|
getLong(field: TemporalField): number;
|
|
2070
2075
|
hashCode(): number;
|
|
2071
2076
|
id(): string;
|
|
2077
|
+
query<R>(query: TemporalQuery<R>): R | null;
|
|
2072
2078
|
rules(): ZoneRules;
|
|
2073
2079
|
toString(): string;
|
|
2074
2080
|
totalSeconds(): number;
|
|
@@ -2219,6 +2225,8 @@ export class DateTimeFormatterBuilder {
|
|
|
2219
2225
|
}
|
|
2220
2226
|
|
|
2221
2227
|
export class DecimalStyle {
|
|
2228
|
+
static STANDARD: DecimalStyle;
|
|
2229
|
+
|
|
2222
2230
|
private constructor();
|
|
2223
2231
|
|
|
2224
2232
|
decimalSeparator(): string;
|
|
@@ -2227,6 +2235,10 @@ export class DecimalStyle {
|
|
|
2227
2235
|
negativeSign(): string;
|
|
2228
2236
|
positiveSign(): string;
|
|
2229
2237
|
toString(): string;
|
|
2238
|
+
withDecimalSeparator(decimalSeparator: string): DecimalStyle;
|
|
2239
|
+
withNegativeSign(negativeSign: string): DecimalStyle;
|
|
2240
|
+
withPositiveSign(positiveSign: string): DecimalStyle;
|
|
2241
|
+
withZeroDigit(zeroDigit: string): DecimalStyle;
|
|
2230
2242
|
zeroDigit(): string;
|
|
2231
2243
|
}
|
|
2232
2244
|
|
|
@@ -2456,10 +2468,13 @@ export class ZoneRulesProvider {
|
|
|
2456
2468
|
export type Chronology = IsoChronology;
|
|
2457
2469
|
|
|
2458
2470
|
export abstract class IsoChronology {
|
|
2471
|
+
static INSTANCE: IsoChronology;
|
|
2472
|
+
|
|
2459
2473
|
static isLeapYear(prolepticYear: number): boolean;
|
|
2460
2474
|
|
|
2461
2475
|
private constructor();
|
|
2462
2476
|
|
|
2477
|
+
date(temporal: TemporalAccessor): LocalDate;
|
|
2463
2478
|
equals(other: any): boolean;
|
|
2464
2479
|
resolveDate(fieldValues: any, resolverStyle: any): any;
|
|
2465
2480
|
toString(): string;
|
package/typings/js-joda.flow.js
CHANGED
|
@@ -108,10 +108,12 @@ declare module "js-joda" {
|
|
|
108
108
|
toMillis(): number;
|
|
109
109
|
toMinutes(): number;
|
|
110
110
|
toNanos(): number;
|
|
111
|
+
toDaysPart(): number;
|
|
111
112
|
toHoursPart(): number;
|
|
112
113
|
toMinutesPart(): number;
|
|
113
114
|
toSecondsPart(): number;
|
|
114
115
|
toMillisPart(): number;
|
|
116
|
+
toNanosPart(): number;
|
|
115
117
|
toString(): string;
|
|
116
118
|
units(): any;
|
|
117
119
|
withNanos(nanoOfSecond: number): Duration;
|
|
@@ -737,6 +739,7 @@ declare module "js-joda" {
|
|
|
737
739
|
now(zoneIdOrClock?: ZoneId | Clock): Year; of(isoYear: number): Year;
|
|
738
740
|
parse(text: string, formatter?: DateTimeFormatter): Year;
|
|
739
741
|
atMonth(monthOrNumber: Month | number): Year;
|
|
742
|
+
format(formatter: DateTimeFormatter): string;
|
|
740
743
|
plus(amountOrNumber: TemporalAmount | number, unit?: TemporalUnit): Year;
|
|
741
744
|
minus(amountOrNumber: TemporalAmount | number, unit?: TemporalUnit): Year
|
|
742
745
|
}
|
|
@@ -938,7 +941,9 @@ declare module "js-joda" {
|
|
|
938
941
|
}
|
|
939
942
|
|
|
940
943
|
declare class IsoChronology {
|
|
944
|
+
INSTANCE: IsoChronology;
|
|
941
945
|
isLeapYear(prolepticYear: number): boolean;
|
|
946
|
+
date(temporal: TemporalAccessor): LocalDate;
|
|
942
947
|
resolveDate(fieldValues: any, resolverStyle: any): any;
|
|
943
948
|
equals(other: any): boolean;
|
|
944
949
|
toString(): string
|