dicom-curate 0.15.0 → 0.15.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.
@@ -18045,7 +18045,7 @@ var require_lib = __commonJS({
18045
18045
  return then;
18046
18046
  };
18047
18047
  exports.end = end;
18048
- var toSeconds2 = function(durationInput, startDate) {
18048
+ var toSeconds = function(durationInput, startDate) {
18049
18049
  if (startDate === void 0) {
18050
18050
  startDate = /* @__PURE__ */ new Date();
18051
18051
  }
@@ -18059,7 +18059,7 @@ var require_lib = __commonJS({
18059
18059
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18060
18060
  return seconds + tzOffsetSeconds;
18061
18061
  };
18062
- exports.toSeconds = toSeconds2;
18062
+ exports.toSeconds = toSeconds;
18063
18063
  exports.default = {
18064
18064
  end: exports.end,
18065
18065
  toSeconds: exports.toSeconds,
@@ -78168,9 +78168,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
78168
78168
  const fractionStr = canonical.slice(15, 21);
78169
78169
  const originalFractionMicro = parseInt(fractionStr, 10);
78170
78170
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
78171
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
78172
- const totalDurationSec = sign * positiveDurationSec;
78173
- const integerDurationSec = Math.trunc(totalDurationSec);
78174
78171
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
78175
78172
  durationFractionMicro = sign * durationFractionMicro;
78176
78173
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -78183,7 +78180,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
78183
78180
  const minute = parseInt(base.slice(10, 12), 10);
78184
78181
  const second = parseInt(base.slice(12, 14), 10);
78185
78182
  const date2 = new Date(year2, month, day, hour, minute, second);
78186
- date2.setSeconds(date2.getSeconds() + integerDurationSec + carry);
78183
+ if (durationParsed.years) {
78184
+ date2.setFullYear(date2.getFullYear() + sign * durationParsed.years);
78185
+ }
78186
+ if (durationParsed.months) {
78187
+ date2.setMonth(date2.getMonth() + sign * durationParsed.months);
78188
+ }
78189
+ if (durationParsed.weeks) {
78190
+ date2.setDate(date2.getDate() + sign * durationParsed.weeks * 7);
78191
+ }
78192
+ if (durationParsed.days) {
78193
+ date2.setDate(date2.getDate() + sign * durationParsed.days);
78194
+ }
78195
+ if (durationParsed.hours) {
78196
+ date2.setHours(date2.getHours() + sign * durationParsed.hours);
78197
+ }
78198
+ if (durationParsed.minutes) {
78199
+ date2.setMinutes(date2.getMinutes() + sign * durationParsed.minutes);
78200
+ }
78201
+ if (durationParsed.seconds) {
78202
+ date2.setSeconds(
78203
+ date2.getSeconds() + sign * Math.trunc(durationParsed.seconds)
78204
+ );
78205
+ }
78206
+ date2.setSeconds(date2.getSeconds() + carry);
78187
78207
  const pad = (n4, width = 2) => n4.toString().padStart(width, "0");
78188
78208
  const newBase = `${date2.getFullYear()}${pad(date2.getMonth() + 1, 2)}${pad(date2.getDate(), 2)}${pad(date2.getHours(), 2)}${pad(date2.getMinutes(), 2)}${pad(date2.getSeconds(), 2)}`;
78189
78209
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -18030,7 +18030,7 @@ var require_lib = __commonJS({
18030
18030
  return then;
18031
18031
  };
18032
18032
  exports.end = end;
18033
- var toSeconds2 = function(durationInput, startDate) {
18033
+ var toSeconds = function(durationInput, startDate) {
18034
18034
  if (startDate === void 0) {
18035
18035
  startDate = /* @__PURE__ */ new Date();
18036
18036
  }
@@ -18044,7 +18044,7 @@ var require_lib = __commonJS({
18044
18044
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18045
18045
  return seconds + tzOffsetSeconds;
18046
18046
  };
18047
- exports.toSeconds = toSeconds2;
18047
+ exports.toSeconds = toSeconds;
18048
18048
  exports.default = {
18049
18049
  end: exports.end,
18050
18050
  toSeconds: exports.toSeconds,
@@ -34162,9 +34162,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34162
34162
  const fractionStr = canonical.slice(15, 21);
34163
34163
  const originalFractionMicro = parseInt(fractionStr, 10);
34164
34164
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
34165
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
34166
- const totalDurationSec = sign * positiveDurationSec;
34167
- const integerDurationSec = Math.trunc(totalDurationSec);
34168
34165
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
34169
34166
  durationFractionMicro = sign * durationFractionMicro;
34170
34167
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -34177,7 +34174,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34177
34174
  const minute = parseInt(base.slice(10, 12), 10);
34178
34175
  const second = parseInt(base.slice(12, 14), 10);
34179
34176
  const date = new Date(year, month, day, hour, minute, second);
34180
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
34177
+ if (durationParsed.years) {
34178
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
34179
+ }
34180
+ if (durationParsed.months) {
34181
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
34182
+ }
34183
+ if (durationParsed.weeks) {
34184
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
34185
+ }
34186
+ if (durationParsed.days) {
34187
+ date.setDate(date.getDate() + sign * durationParsed.days);
34188
+ }
34189
+ if (durationParsed.hours) {
34190
+ date.setHours(date.getHours() + sign * durationParsed.hours);
34191
+ }
34192
+ if (durationParsed.minutes) {
34193
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
34194
+ }
34195
+ if (durationParsed.seconds) {
34196
+ date.setSeconds(
34197
+ date.getSeconds() + sign * Math.trunc(durationParsed.seconds)
34198
+ );
34199
+ }
34200
+ date.setSeconds(date.getSeconds() + carry);
34181
34201
  const pad = (n, width = 2) => n.toString().padStart(width, "0");
34182
34202
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;
34183
34203
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -18025,7 +18025,7 @@ var require_lib = __commonJS({
18025
18025
  return then;
18026
18026
  };
18027
18027
  exports.end = end;
18028
- var toSeconds2 = function(durationInput, startDate) {
18028
+ var toSeconds = function(durationInput, startDate) {
18029
18029
  if (startDate === void 0) {
18030
18030
  startDate = /* @__PURE__ */ new Date();
18031
18031
  }
@@ -18039,7 +18039,7 @@ var require_lib = __commonJS({
18039
18039
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18040
18040
  return seconds + tzOffsetSeconds;
18041
18041
  };
18042
- exports.toSeconds = toSeconds2;
18042
+ exports.toSeconds = toSeconds;
18043
18043
  exports.default = {
18044
18044
  end: exports.end,
18045
18045
  toSeconds: exports.toSeconds,
@@ -18030,7 +18030,7 @@ var require_lib = __commonJS({
18030
18030
  return then;
18031
18031
  };
18032
18032
  exports.end = end;
18033
- var toSeconds2 = function(durationInput, startDate) {
18033
+ var toSeconds = function(durationInput, startDate) {
18034
18034
  if (startDate === void 0) {
18035
18035
  startDate = /* @__PURE__ */ new Date();
18036
18036
  }
@@ -18044,7 +18044,7 @@ var require_lib = __commonJS({
18044
18044
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18045
18045
  return seconds + tzOffsetSeconds;
18046
18046
  };
18047
- exports.toSeconds = toSeconds2;
18047
+ exports.toSeconds = toSeconds;
18048
18048
  exports.default = {
18049
18049
  end: exports.end,
18050
18050
  toSeconds: exports.toSeconds,
@@ -34179,9 +34179,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34179
34179
  const fractionStr = canonical.slice(15, 21);
34180
34180
  const originalFractionMicro = parseInt(fractionStr, 10);
34181
34181
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
34182
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
34183
- const totalDurationSec = sign * positiveDurationSec;
34184
- const integerDurationSec = Math.trunc(totalDurationSec);
34185
34182
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
34186
34183
  durationFractionMicro = sign * durationFractionMicro;
34187
34184
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -34194,7 +34191,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34194
34191
  const minute = parseInt(base.slice(10, 12), 10);
34195
34192
  const second = parseInt(base.slice(12, 14), 10);
34196
34193
  const date = new Date(year, month, day, hour, minute, second);
34197
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
34194
+ if (durationParsed.years) {
34195
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
34196
+ }
34197
+ if (durationParsed.months) {
34198
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
34199
+ }
34200
+ if (durationParsed.weeks) {
34201
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
34202
+ }
34203
+ if (durationParsed.days) {
34204
+ date.setDate(date.getDate() + sign * durationParsed.days);
34205
+ }
34206
+ if (durationParsed.hours) {
34207
+ date.setHours(date.getHours() + sign * durationParsed.hours);
34208
+ }
34209
+ if (durationParsed.minutes) {
34210
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
34211
+ }
34212
+ if (durationParsed.seconds) {
34213
+ date.setSeconds(
34214
+ date.getSeconds() + sign * Math.trunc(durationParsed.seconds)
34215
+ );
34216
+ }
34217
+ date.setSeconds(date.getSeconds() + carry);
34198
34218
  const pad = (n, width = 2) => n.toString().padStart(width, "0");
34199
34219
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;
34200
34220
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -18045,7 +18045,7 @@ var require_lib = __commonJS({
18045
18045
  return then;
18046
18046
  };
18047
18047
  exports.end = end;
18048
- var toSeconds2 = function(durationInput, startDate) {
18048
+ var toSeconds = function(durationInput, startDate) {
18049
18049
  if (startDate === void 0) {
18050
18050
  startDate = /* @__PURE__ */ new Date();
18051
18051
  }
@@ -18059,7 +18059,7 @@ var require_lib = __commonJS({
18059
18059
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18060
18060
  return seconds + tzOffsetSeconds;
18061
18061
  };
18062
- exports.toSeconds = toSeconds2;
18062
+ exports.toSeconds = toSeconds;
18063
18063
  exports.default = {
18064
18064
  end: exports.end,
18065
18065
  toSeconds: exports.toSeconds,
@@ -71877,9 +71877,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
71877
71877
  const fractionStr = canonical.slice(15, 21);
71878
71878
  const originalFractionMicro = parseInt(fractionStr, 10);
71879
71879
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
71880
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
71881
- const totalDurationSec = sign * positiveDurationSec;
71882
- const integerDurationSec = Math.trunc(totalDurationSec);
71883
71880
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
71884
71881
  durationFractionMicro = sign * durationFractionMicro;
71885
71882
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -71892,7 +71889,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
71892
71889
  const minute = parseInt(base.slice(10, 12), 10);
71893
71890
  const second = parseInt(base.slice(12, 14), 10);
71894
71891
  const date2 = new Date(year2, month, day, hour, minute, second);
71895
- date2.setSeconds(date2.getSeconds() + integerDurationSec + carry);
71892
+ if (durationParsed.years) {
71893
+ date2.setFullYear(date2.getFullYear() + sign * durationParsed.years);
71894
+ }
71895
+ if (durationParsed.months) {
71896
+ date2.setMonth(date2.getMonth() + sign * durationParsed.months);
71897
+ }
71898
+ if (durationParsed.weeks) {
71899
+ date2.setDate(date2.getDate() + sign * durationParsed.weeks * 7);
71900
+ }
71901
+ if (durationParsed.days) {
71902
+ date2.setDate(date2.getDate() + sign * durationParsed.days);
71903
+ }
71904
+ if (durationParsed.hours) {
71905
+ date2.setHours(date2.getHours() + sign * durationParsed.hours);
71906
+ }
71907
+ if (durationParsed.minutes) {
71908
+ date2.setMinutes(date2.getMinutes() + sign * durationParsed.minutes);
71909
+ }
71910
+ if (durationParsed.seconds) {
71911
+ date2.setSeconds(
71912
+ date2.getSeconds() + sign * Math.trunc(durationParsed.seconds)
71913
+ );
71914
+ }
71915
+ date2.setSeconds(date2.getSeconds() + carry);
71896
71916
  const pad = (n4, width = 2) => n4.toString().padStart(width, "0");
71897
71917
  const newBase = `${date2.getFullYear()}${pad(date2.getMonth() + 1, 2)}${pad(date2.getDate(), 2)}${pad(date2.getHours(), 2)}${pad(date2.getMinutes(), 2)}${pad(date2.getSeconds(), 2)}`;
71898
71918
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -18025,7 +18025,7 @@ var require_lib = __commonJS({
18025
18025
  return then;
18026
18026
  };
18027
18027
  exports.end = end;
18028
- var toSeconds2 = function(durationInput, startDate) {
18028
+ var toSeconds = function(durationInput, startDate) {
18029
18029
  if (startDate === void 0) {
18030
18030
  startDate = /* @__PURE__ */ new Date();
18031
18031
  }
@@ -18039,7 +18039,7 @@ var require_lib = __commonJS({
18039
18039
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18040
18040
  return seconds + tzOffsetSeconds;
18041
18041
  };
18042
- exports.toSeconds = toSeconds2;
18042
+ exports.toSeconds = toSeconds;
18043
18043
  exports.default = {
18044
18044
  end: exports.end,
18045
18045
  toSeconds: exports.toSeconds,
@@ -18030,7 +18030,7 @@ var require_lib = __commonJS({
18030
18030
  return then;
18031
18031
  };
18032
18032
  exports.end = end;
18033
- var toSeconds2 = function(durationInput, startDate) {
18033
+ var toSeconds = function(durationInput, startDate) {
18034
18034
  if (startDate === void 0) {
18035
18035
  startDate = /* @__PURE__ */ new Date();
18036
18036
  }
@@ -18044,7 +18044,7 @@ var require_lib = __commonJS({
18044
18044
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18045
18045
  return seconds + tzOffsetSeconds;
18046
18046
  };
18047
- exports.toSeconds = toSeconds2;
18047
+ exports.toSeconds = toSeconds;
18048
18048
  exports.default = {
18049
18049
  end: exports.end,
18050
18050
  toSeconds: exports.toSeconds,
@@ -34156,9 +34156,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34156
34156
  const fractionStr = canonical.slice(15, 21);
34157
34157
  const originalFractionMicro = parseInt(fractionStr, 10);
34158
34158
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
34159
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
34160
- const totalDurationSec = sign * positiveDurationSec;
34161
- const integerDurationSec = Math.trunc(totalDurationSec);
34162
34159
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
34163
34160
  durationFractionMicro = sign * durationFractionMicro;
34164
34161
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -34171,7 +34168,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
34171
34168
  const minute = parseInt(base.slice(10, 12), 10);
34172
34169
  const second = parseInt(base.slice(12, 14), 10);
34173
34170
  const date = new Date(year, month, day, hour, minute, second);
34174
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
34171
+ if (durationParsed.years) {
34172
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
34173
+ }
34174
+ if (durationParsed.months) {
34175
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
34176
+ }
34177
+ if (durationParsed.weeks) {
34178
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
34179
+ }
34180
+ if (durationParsed.days) {
34181
+ date.setDate(date.getDate() + sign * durationParsed.days);
34182
+ }
34183
+ if (durationParsed.hours) {
34184
+ date.setHours(date.getHours() + sign * durationParsed.hours);
34185
+ }
34186
+ if (durationParsed.minutes) {
34187
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
34188
+ }
34189
+ if (durationParsed.seconds) {
34190
+ date.setSeconds(
34191
+ date.getSeconds() + sign * Math.trunc(durationParsed.seconds)
34192
+ );
34193
+ }
34194
+ date.setSeconds(date.getSeconds() + carry);
34175
34195
  const pad = (n, width = 2) => n.toString().padStart(width, "0");
34176
34196
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;
34177
34197
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -18030,7 +18030,7 @@ var require_lib = __commonJS({
18030
18030
  return then;
18031
18031
  };
18032
18032
  exports.end = end;
18033
- var toSeconds2 = function(durationInput, startDate) {
18033
+ var toSeconds = function(durationInput, startDate) {
18034
18034
  if (startDate === void 0) {
18035
18035
  startDate = /* @__PURE__ */ new Date();
18036
18036
  }
@@ -18044,7 +18044,7 @@ var require_lib = __commonJS({
18044
18044
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18045
18045
  return seconds + tzOffsetSeconds;
18046
18046
  };
18047
- exports.toSeconds = toSeconds2;
18047
+ exports.toSeconds = toSeconds;
18048
18048
  exports.default = {
18049
18049
  end: exports.end,
18050
18050
  toSeconds: exports.toSeconds,
package/dist/esm/index.js CHANGED
@@ -18045,7 +18045,7 @@ var require_lib = __commonJS({
18045
18045
  return then;
18046
18046
  };
18047
18047
  exports.end = end;
18048
- var toSeconds2 = function(durationInput, startDate) {
18048
+ var toSeconds = function(durationInput, startDate) {
18049
18049
  if (startDate === void 0) {
18050
18050
  startDate = /* @__PURE__ */ new Date();
18051
18051
  }
@@ -18059,7 +18059,7 @@ var require_lib = __commonJS({
18059
18059
  var seconds = (then.getTime() - now.getTime()) / 1e3;
18060
18060
  return seconds + tzOffsetSeconds;
18061
18061
  };
18062
- exports.toSeconds = toSeconds2;
18062
+ exports.toSeconds = toSeconds;
18063
18063
  exports.default = {
18064
18064
  end: exports.end,
18065
18065
  toSeconds: exports.toSeconds,
@@ -78205,9 +78205,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
78205
78205
  const fractionStr = canonical.slice(15, 21);
78206
78206
  const originalFractionMicro = parseInt(fractionStr, 10);
78207
78207
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
78208
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
78209
- const totalDurationSec = sign * positiveDurationSec;
78210
- const integerDurationSec = Math.trunc(totalDurationSec);
78211
78208
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
78212
78209
  durationFractionMicro = sign * durationFractionMicro;
78213
78210
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -78220,7 +78217,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
78220
78217
  const minute = parseInt(base.slice(10, 12), 10);
78221
78218
  const second = parseInt(base.slice(12, 14), 10);
78222
78219
  const date2 = new Date(year2, month, day, hour, minute, second);
78223
- date2.setSeconds(date2.getSeconds() + integerDurationSec + carry);
78220
+ if (durationParsed.years) {
78221
+ date2.setFullYear(date2.getFullYear() + sign * durationParsed.years);
78222
+ }
78223
+ if (durationParsed.months) {
78224
+ date2.setMonth(date2.getMonth() + sign * durationParsed.months);
78225
+ }
78226
+ if (durationParsed.weeks) {
78227
+ date2.setDate(date2.getDate() + sign * durationParsed.weeks * 7);
78228
+ }
78229
+ if (durationParsed.days) {
78230
+ date2.setDate(date2.getDate() + sign * durationParsed.days);
78231
+ }
78232
+ if (durationParsed.hours) {
78233
+ date2.setHours(date2.getHours() + sign * durationParsed.hours);
78234
+ }
78235
+ if (durationParsed.minutes) {
78236
+ date2.setMinutes(date2.getMinutes() + sign * durationParsed.minutes);
78237
+ }
78238
+ if (durationParsed.seconds) {
78239
+ date2.setSeconds(
78240
+ date2.getSeconds() + sign * Math.trunc(durationParsed.seconds)
78241
+ );
78242
+ }
78243
+ date2.setSeconds(date2.getSeconds() + carry);
78224
78244
  const pad = (n4, width = 2) => n4.toString().padStart(width, "0");
78225
78245
  const newBase = `${date2.getFullYear()}${pad(date2.getMonth() + 1, 2)}${pad(date2.getDate(), 2)}${pad(date2.getHours(), 2)}${pad(date2.getMinutes(), 2)}${pad(date2.getSeconds(), 2)}`;
78226
78246
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -93,7 +93,7 @@ var require_lib = __commonJS({
93
93
  return then;
94
94
  };
95
95
  exports.end = end;
96
- var toSeconds2 = function(durationInput, startDate) {
96
+ var toSeconds = function(durationInput, startDate) {
97
97
  if (startDate === void 0) {
98
98
  startDate = /* @__PURE__ */ new Date();
99
99
  }
@@ -107,7 +107,7 @@ var require_lib = __commonJS({
107
107
  var seconds = (then.getTime() - now.getTime()) / 1e3;
108
108
  return seconds + tzOffsetSeconds;
109
109
  };
110
- exports.toSeconds = toSeconds2;
110
+ exports.toSeconds = toSeconds;
111
111
  exports.default = {
112
112
  end: exports.end,
113
113
  toSeconds: exports.toSeconds,
@@ -271,9 +271,6 @@ function offsetDateTime(dicomValue, iso8601Duration) {
271
271
  const fractionStr = canonical.slice(15, 21);
272
272
  const originalFractionMicro = parseInt(fractionStr, 10);
273
273
  const durationParsed = (0, import_iso8601_duration.parse)(durationStr);
274
- const positiveDurationSec = (0, import_iso8601_duration.toSeconds)(durationParsed);
275
- const totalDurationSec = sign * positiveDurationSec;
276
- const integerDurationSec = Math.trunc(totalDurationSec);
277
274
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
278
275
  durationFractionMicro = sign * durationFractionMicro;
279
276
  const totalFractionMicro = originalFractionMicro + durationFractionMicro;
@@ -286,7 +283,30 @@ function offsetDateTime(dicomValue, iso8601Duration) {
286
283
  const minute = parseInt(base.slice(10, 12), 10);
287
284
  const second = parseInt(base.slice(12, 14), 10);
288
285
  const date = new Date(year, month, day, hour, minute, second);
289
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
286
+ if (durationParsed.years) {
287
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
288
+ }
289
+ if (durationParsed.months) {
290
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
291
+ }
292
+ if (durationParsed.weeks) {
293
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
294
+ }
295
+ if (durationParsed.days) {
296
+ date.setDate(date.getDate() + sign * durationParsed.days);
297
+ }
298
+ if (durationParsed.hours) {
299
+ date.setHours(date.getHours() + sign * durationParsed.hours);
300
+ }
301
+ if (durationParsed.minutes) {
302
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
303
+ }
304
+ if (durationParsed.seconds) {
305
+ date.setSeconds(
306
+ date.getSeconds() + sign * Math.trunc(durationParsed.seconds)
307
+ );
308
+ }
309
+ date.setSeconds(date.getSeconds() + carry);
290
310
  const pad = (n, width = 2) => n.toString().padStart(width, "0");
291
311
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;
292
312
  const newFractionStr = newFractionMicro.toString().padStart(6, "0");
@@ -17,13 +17,17 @@ export declare function canonicalDTToDicom(canonicalDT: string, original: string
17
17
  * 1. Converts the original DICOM string into a canonical DT string ("YYYYMMDDHHMMSS.FFFFFF").
18
18
  * 2. Splits that canonical string into its integer base (14-digit) and 6-digit fractional part.
19
19
  * 3. Checks if the duration is negative (by looking for a leading "-") and, if so, removes the minus and records the sign.
20
- * 4. Parses the ISO8601 duration using the package for the integer seconds (and larger units)
21
- * and extracts the fractional part (in microseconds) manually.
22
- * 5. Uses Math.trunc to split the (possibly negative) total seconds into integer and fractional parts.
23
- * 6. Performs microsecond arithmetic to add the fractions, carrying whole seconds as needed.
24
- * 7. Uses JavaScript Date arithmetic for the integer seconds.
20
+ * 4. Parses the ISO8601 duration using the package for the calendar units (years, months, days)
21
+ * and time units (hours, minutes, seconds) separately.
22
+ * 5. Uses JavaScript Date methods for calendar arithmetic (years, months, days).
23
+ * 6. Uses Date methods for time arithmetic (hours, minutes, seconds).
24
+ * 7. Performs microsecond arithmetic to add the fractional seconds, carrying whole seconds as needed.
25
25
  * 8. Reassembles a new canonical DT string and converts it back to the original DICOM format.
26
26
  *
27
+ * Note: This function uses JavaScript's Date arithmetic, which means it exhibits standard overflow behavior.
28
+ * For example: Jan 31 + 1 month = March 3 (Feb 31 doesn't exist, so it overflows).
29
+ * Similarly: Feb 29, 2024 + 1 year = March 1, 2025 (2025 is not a leap year).
30
+ *
27
31
  * @param dicomValue - The original DICOM date/time string.
28
32
  * @param iso8601Duration - An ISO8601 duration string (e.g., "PT1.111111S", "-P5D", "-PT1.111111S", etc.).
29
33
  * @returns The offset DICOM string, formatted like the original.
@@ -28,7 +28,7 @@ export type OrganizeOptions = {
28
28
  skipValidation?: boolean;
29
29
  dateOffset?: Iso8601Duration;
30
30
  skipCollectingMappings?: boolean;
31
- hashMethod?: 'crc64' | 'crc32' | 'sha256';
31
+ hashMethod?: THashMethod;
32
32
  fileInfoIndex?: TFileInfoIndex;
33
33
  } & ({
34
34
  inputType: 'directory';
@@ -28948,13 +28948,17 @@
28948
28948
  * 1. Converts the original DICOM string into a canonical DT string ("YYYYMMDDHHMMSS.FFFFFF").
28949
28949
  * 2. Splits that canonical string into its integer base (14-digit) and 6-digit fractional part.
28950
28950
  * 3. Checks if the duration is negative (by looking for a leading "-") and, if so, removes the minus and records the sign.
28951
- * 4. Parses the ISO8601 duration using the package for the integer seconds (and larger units)
28952
- * and extracts the fractional part (in microseconds) manually.
28953
- * 5. Uses Math.trunc to split the (possibly negative) total seconds into integer and fractional parts.
28954
- * 6. Performs microsecond arithmetic to add the fractions, carrying whole seconds as needed.
28955
- * 7. Uses JavaScript Date arithmetic for the integer seconds.
28951
+ * 4. Parses the ISO8601 duration using the package for the calendar units (years, months, days)
28952
+ * and time units (hours, minutes, seconds) separately.
28953
+ * 5. Uses JavaScript Date methods for calendar arithmetic (years, months, days).
28954
+ * 6. Uses Date methods for time arithmetic (hours, minutes, seconds).
28955
+ * 7. Performs microsecond arithmetic to add the fractional seconds, carrying whole seconds as needed.
28956
28956
  * 8. Reassembles a new canonical DT string and converts it back to the original DICOM format.
28957
28957
  *
28958
+ * Note: This function uses JavaScript's Date arithmetic, which means it exhibits standard overflow behavior.
28959
+ * For example: Jan 31 + 1 month = March 3 (Feb 31 doesn't exist, so it overflows).
28960
+ * Similarly: Feb 29, 2024 + 1 year = March 1, 2025 (2025 is not a leap year).
28961
+ *
28958
28962
  * @param dicomValue - The original DICOM date/time string.
28959
28963
  * @param iso8601Duration - An ISO8601 duration string (e.g., "PT1.111111S", "-P5D", "-PT1.111111S", etc.).
28960
28964
  * @returns The offset DICOM string, formatted like the original.
@@ -28977,9 +28981,6 @@
28977
28981
  const originalFractionMicro = parseInt(fractionStr, 10); // as an integer microseconds
28978
28982
  // Step 3: Parse the ISO8601 duration (without the sign).
28979
28983
  const durationParsed = libExports.parse(durationStr);
28980
- const positiveDurationSec = libExports.toSeconds(durationParsed); // positive value
28981
- const totalDurationSec = sign * positiveDurationSec; // apply the sign
28982
- const integerDurationSec = Math.trunc(totalDurationSec); // using trunc so that, e.g., -1.111111 becomes -1
28983
28984
  // Step 4: Extract the fractional part (microseconds) from the duration string and apply the sign.
28984
28985
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
28985
28986
  durationFractionMicro = sign * durationFractionMicro;
@@ -28995,8 +28996,33 @@
28995
28996
  const minute = parseInt(base.slice(10, 12), 10);
28996
28997
  const second = parseInt(base.slice(12, 14), 10);
28997
28998
  const date = new Date(year, month, day, hour, minute, second);
28998
- // Step 7: Add the integer seconds plus any carry from the fractional addition.
28999
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
28999
+ // Step 7: Apply calendar arithmetic using Date methods to handle variable-length months/years correctly.
29000
+ // Apply years, months, and weeks first (calendar units)
29001
+ if (durationParsed.years) {
29002
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
29003
+ }
29004
+ if (durationParsed.months) {
29005
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
29006
+ }
29007
+ if (durationParsed.weeks) {
29008
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
29009
+ }
29010
+ if (durationParsed.days) {
29011
+ date.setDate(date.getDate() + sign * durationParsed.days);
29012
+ }
29013
+ // Apply time units (hours, minutes, seconds)
29014
+ if (durationParsed.hours) {
29015
+ date.setHours(date.getHours() + sign * durationParsed.hours);
29016
+ }
29017
+ if (durationParsed.minutes) {
29018
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
29019
+ }
29020
+ if (durationParsed.seconds) {
29021
+ // Use only the integer part of seconds since fractional part is handled separately
29022
+ date.setSeconds(date.getSeconds() + sign * Math.trunc(durationParsed.seconds));
29023
+ }
29024
+ // Apply any carry from fractional seconds
29025
+ date.setSeconds(date.getSeconds() + carry);
29000
29026
  // Step 8: Reassemble a new canonical DT string.
29001
29027
  const pad = (n, width = 2) => n.toString().padStart(width, '0');
29002
29028
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;
@@ -90809,13 +90835,17 @@
90809
90835
  * 1. Converts the original DICOM string into a canonical DT string ("YYYYMMDDHHMMSS.FFFFFF").
90810
90836
  * 2. Splits that canonical string into its integer base (14-digit) and 6-digit fractional part.
90811
90837
  * 3. Checks if the duration is negative (by looking for a leading "-") and, if so, removes the minus and records the sign.
90812
- * 4. Parses the ISO8601 duration using the package for the integer seconds (and larger units)
90813
- * and extracts the fractional part (in microseconds) manually.
90814
- * 5. Uses Math.trunc to split the (possibly negative) total seconds into integer and fractional parts.
90815
- * 6. Performs microsecond arithmetic to add the fractions, carrying whole seconds as needed.
90816
- * 7. Uses JavaScript Date arithmetic for the integer seconds.
90838
+ * 4. Parses the ISO8601 duration using the package for the calendar units (years, months, days)
90839
+ * and time units (hours, minutes, seconds) separately.
90840
+ * 5. Uses JavaScript Date methods for calendar arithmetic (years, months, days).
90841
+ * 6. Uses Date methods for time arithmetic (hours, minutes, seconds).
90842
+ * 7. Performs microsecond arithmetic to add the fractional seconds, carrying whole seconds as needed.
90817
90843
  * 8. Reassembles a new canonical DT string and converts it back to the original DICOM format.
90818
90844
  *
90845
+ * Note: This function uses JavaScript's Date arithmetic, which means it exhibits standard overflow behavior.
90846
+ * For example: Jan 31 + 1 month = March 3 (Feb 31 doesn't exist, so it overflows).
90847
+ * Similarly: Feb 29, 2024 + 1 year = March 1, 2025 (2025 is not a leap year).
90848
+ *
90819
90849
  * @param dicomValue - The original DICOM date/time string.
90820
90850
  * @param iso8601Duration - An ISO8601 duration string (e.g., "PT1.111111S", "-P5D", "-PT1.111111S", etc.).
90821
90851
  * @returns The offset DICOM string, formatted like the original.
@@ -90838,9 +90868,6 @@
90838
90868
  const originalFractionMicro = parseInt(fractionStr, 10); // as an integer microseconds
90839
90869
  // Step 3: Parse the ISO8601 duration (without the sign).
90840
90870
  const durationParsed = libExports.parse(durationStr);
90841
- const positiveDurationSec = libExports.toSeconds(durationParsed); // positive value
90842
- const totalDurationSec = sign * positiveDurationSec; // apply the sign
90843
- const integerDurationSec = Math.trunc(totalDurationSec); // using trunc so that, e.g., -1.111111 becomes -1
90844
90871
  // Step 4: Extract the fractional part (microseconds) from the duration string and apply the sign.
90845
90872
  let durationFractionMicro = getDurationFractionMicroseconds(durationStr);
90846
90873
  durationFractionMicro = sign * durationFractionMicro;
@@ -90856,8 +90883,33 @@
90856
90883
  const minute = parseInt(base.slice(10, 12), 10);
90857
90884
  const second = parseInt(base.slice(12, 14), 10);
90858
90885
  const date = new Date(year, month, day, hour, minute, second);
90859
- // Step 7: Add the integer seconds plus any carry from the fractional addition.
90860
- date.setSeconds(date.getSeconds() + integerDurationSec + carry);
90886
+ // Step 7: Apply calendar arithmetic using Date methods to handle variable-length months/years correctly.
90887
+ // Apply years, months, and weeks first (calendar units)
90888
+ if (durationParsed.years) {
90889
+ date.setFullYear(date.getFullYear() + sign * durationParsed.years);
90890
+ }
90891
+ if (durationParsed.months) {
90892
+ date.setMonth(date.getMonth() + sign * durationParsed.months);
90893
+ }
90894
+ if (durationParsed.weeks) {
90895
+ date.setDate(date.getDate() + sign * durationParsed.weeks * 7);
90896
+ }
90897
+ if (durationParsed.days) {
90898
+ date.setDate(date.getDate() + sign * durationParsed.days);
90899
+ }
90900
+ // Apply time units (hours, minutes, seconds)
90901
+ if (durationParsed.hours) {
90902
+ date.setHours(date.getHours() + sign * durationParsed.hours);
90903
+ }
90904
+ if (durationParsed.minutes) {
90905
+ date.setMinutes(date.getMinutes() + sign * durationParsed.minutes);
90906
+ }
90907
+ if (durationParsed.seconds) {
90908
+ // Use only the integer part of seconds since fractional part is handled separately
90909
+ date.setSeconds(date.getSeconds() + sign * Math.trunc(durationParsed.seconds));
90910
+ }
90911
+ // Apply any carry from fractional seconds
90912
+ date.setSeconds(date.getSeconds() + carry);
90861
90913
  // Step 8: Reassemble a new canonical DT string.
90862
90914
  const pad = (n, width = 2) => n.toString().padStart(width, '0');
90863
90915
  const newBase = `${date.getFullYear()}${pad(date.getMonth() + 1, 2)}${pad(date.getDate(), 2)}${pad(date.getHours(), 2)}${pad(date.getMinutes(), 2)}${pad(date.getSeconds(), 2)}`;