@js-joda/core 5.6.5 → 5.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-joda/core",
3
- "version": "5.6.5",
3
+ "version": "5.7.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": "0e0db1449c1ac7eb1d38ba0852fa11e3ae598e48"
51
+ "gitHead": "de894726b34edb1596a821273e08e93b76096d23"
52
52
  }
package/src/Duration.js CHANGED
@@ -1080,6 +1080,69 @@ export class Duration extends TemporalAmount /*implements TemporalAmount, Compar
1080
1080
  return totalNanos;
1081
1081
  }
1082
1082
 
1083
+ //-----------------------------------------------------------------------
1084
+ /**
1085
+ * Extracts the number of hours part in the duration.
1086
+ *
1087
+ * This returns the number of remaining hours when dividing {@link Duration.toHours}
1088
+ * by hours in a day.
1089
+ * This is based on the standard definition of a day as 24 hours.
1090
+ *
1091
+ * This instance is immutable and unaffected by this method call.
1092
+ *
1093
+ * @return {number} the number of hours part in the duration, may be negative
1094
+ */
1095
+ toHoursPart() {
1096
+ return MathUtil.intMod(this.toHours(), LocalTime.HOURS_PER_DAY);
1097
+ }
1098
+
1099
+ /**
1100
+ * Extracts the number of minutes part in the duration.
1101
+ *
1102
+ * This returns the number of remaining minutes when dividing {@link Duration.toMinutes}
1103
+ * by minutes in an hour.
1104
+ * This is based on the standard definition of an hour as 60 minutes.
1105
+ *
1106
+ * This instance is immutable and unaffected by this method call.
1107
+ *
1108
+ * @return {number} the number of minutes parts in the duration, may be negative
1109
+ */
1110
+ toMinutesPart() {
1111
+ return MathUtil.intMod(this.toMinutes(), LocalTime.MINUTES_PER_HOUR);
1112
+ }
1113
+
1114
+ /**
1115
+ * Extracts the number of seconds part in the duration.
1116
+ *
1117
+ * This returns the remaining seconds when dividing {@link Duration.toSeconds}
1118
+ * by seconds in a minute.
1119
+ * This is based on the standard definition of a minute as 60 seconds.
1120
+ *
1121
+ * This instance is immutable and unaffected by this method call.
1122
+ *
1123
+ * @return {number} the number of seconds parts in the duration, may be negative
1124
+ */
1125
+ toSecondsPart() {
1126
+ return MathUtil.intMod(this._seconds, LocalTime.SECONDS_PER_MINUTE);
1127
+ }
1128
+
1129
+ /**
1130
+ * Extracts the number of milliseconds part of the duration.
1131
+ *
1132
+ * This returns the milliseconds part by dividing the number of nanoseconds by 1,000,000.
1133
+ * The length of the duration is stored using two fields - seconds and nanoseconds.
1134
+ * The nanoseconds part is a value from 0 to 999,999,999 that is an adjustment to
1135
+ * the length in seconds.
1136
+ * The total duration is defined by calling {@link Duration.nano} and {@link Duration.seconds}.
1137
+ *
1138
+ * This instance is immutable and unaffected by this method call.
1139
+ *
1140
+ * @return {number} the number of milliseconds part of the duration.
1141
+ */
1142
+ toMillisPart() {
1143
+ return MathUtil.intDiv(this._nanos, 1000000);
1144
+ }
1145
+
1083
1146
  //-----------------------------------------------------------------------
1084
1147
  /**
1085
1148
  * Compares this duration to the specified {@link Duration}.
@@ -12,13 +12,15 @@ export class ZoneRulesProvider {
12
12
  *
13
13
  * This returns the latest available rules for the zone ID.
14
14
  *
15
- * This method relies on time-zone data provider files that are configured.
15
+ * This method relies on `@js-joda/timezone` being imported first (for
16
+ * side effects).
16
17
  *
17
18
  * @param {string} zoneId
18
19
  * @return {ZoneRules}
19
20
  */
20
- static getRules(zoneId){
21
- throw new DateTimeException(`unsupported ZoneId:${zoneId}`);
21
+ // eslint-disable-next-line no-unused-vars
22
+ static getRules(_zoneId){
23
+ throw new DateTimeException('@js-joda/timezone not imported');
22
24
  }
23
25
 
24
26
 
@@ -1136,6 +1136,10 @@ export class Duration extends TemporalAmount {
1136
1136
  toMillis(): number;
1137
1137
  toMinutes(): number;
1138
1138
  toNanos(): number;
1139
+ toHoursPart(): number;
1140
+ toMinutesPart(): number;
1141
+ toSecondsPart(): number;
1142
+ toMillisPart(): number;
1139
1143
  toString(): string;
1140
1144
  units(): TemporalUnit[];
1141
1145
  withNanos(nanoOfSecond: number): Duration;
@@ -108,6 +108,10 @@ declare module "js-joda" {
108
108
  toMillis(): number;
109
109
  toMinutes(): number;
110
110
  toNanos(): number;
111
+ toHoursPart(): number;
112
+ toMinutesPart(): number;
113
+ toSecondspart(): number;
114
+ toMillisPart(): number;
111
115
  toString(): string;
112
116
  units(): any;
113
117
  withNanos(nanoOfSecond: number): Duration;