sandbox 2.5.10 → 2.5.12

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.
@@ -3004,6 +3004,7 @@ const runtime = import_cjs$23.option({
3004
3004
  ...import_cjs$23.oneOf([
3005
3005
  "node22",
3006
3006
  "node24",
3007
+ "node26",
3007
3008
  "python3.13"
3008
3009
  ]),
3009
3010
  displayName: "runtime"
@@ -3155,7 +3156,7 @@ var import_cjs$21 = /* @__PURE__ */ __toESM(require_cjs());
3155
3156
  const timeout = import_cjs$21.option({
3156
3157
  long: "timeout",
3157
3158
  type: Duration,
3158
- description: "The maximum duration a sandbox can run for. Example: 5m, 1h",
3159
+ description: "The maximum duration a sandbox can run for. Example: 5m, 30m",
3159
3160
  defaultValue: () => "5 minutes",
3160
3161
  defaultValueIsSerializable: true
3161
3162
  });
@@ -3240,7 +3241,7 @@ const formatDistanceLocale = {
3240
3241
  other: "almost {{count}} years"
3241
3242
  }
3242
3243
  };
3243
- const formatDistance$1 = (token$1, count, options) => {
3244
+ const formatDistance = (token$1, count, options) => {
3244
3245
  let result;
3245
3246
  const tokenValue = formatDistanceLocale[token$1];
3246
3247
  if (typeof tokenValue === "string") result = tokenValue;
@@ -3762,7 +3763,7 @@ const match = {
3762
3763
  */
3763
3764
  const enUS = {
3764
3765
  code: "en-US",
3765
- formatDistance: formatDistance$1,
3766
+ formatDistance,
3766
3767
  formatLong,
3767
3768
  formatRelative,
3768
3769
  localize,
@@ -3780,6 +3781,15 @@ function getDefaultOptions() {
3780
3781
  return defaultOptions;
3781
3782
  }
3782
3783
 
3784
+ //#endregion
3785
+ //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getRoundingMethod.js
3786
+ function getRoundingMethod(method) {
3787
+ return (number) => {
3788
+ const result = (method ? Math[method] : Math.trunc)(number);
3789
+ return result === 0 ? 0 : result;
3790
+ };
3791
+ }
3792
+
3783
3793
  //#endregion
3784
3794
  //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js
3785
3795
  /**
@@ -3813,6 +3823,18 @@ const daysInYear = 365.2425;
3813
3823
  const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
3814
3824
  /**
3815
3825
  * @constant
3826
+ * @name millisecondsInMinute
3827
+ * @summary Milliseconds in 1 minute
3828
+ */
3829
+ const millisecondsInMinute = 6e4;
3830
+ /**
3831
+ * @constant
3832
+ * @name minutesInYear
3833
+ * @summary Minutes in 1 year.
3834
+ */
3835
+ const minutesInYear = 525600;
3836
+ /**
3837
+ * @constant
3816
3838
  * @name minutesInMonth
3817
3839
  * @summary Minutes in 1 month.
3818
3840
  */
@@ -4029,277 +4051,31 @@ function compareAsc(dateLeft, dateRight) {
4029
4051
  }
4030
4052
 
4031
4053
  //#endregion
4032
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInCalendarMonths.js
4054
+ //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/formatDistanceStrict.js
4033
4055
  /**
4034
- * The {@link differenceInCalendarMonths} function options.
4056
+ * The {@link formatDistanceStrict} function options.
4035
4057
  */
4036
4058
  /**
4037
- * @name differenceInCalendarMonths
4038
- * @category Month Helpers
4039
- * @summary Get the number of calendar months between the given dates.
4040
- *
4041
- * @description
4042
- * Get the number of calendar months between the given dates.
4043
- *
4044
- * @param laterDate - The later date
4045
- * @param earlierDate - The earlier date
4046
- * @param options - An object with options
4047
- *
4048
- * @returns The number of calendar months
4049
- *
4050
- * @example
4051
- * // How many calendar months are between 31 January 2014 and 1 September 2014?
4052
- * const result = differenceInCalendarMonths(
4053
- * new Date(2014, 8, 1),
4054
- * new Date(2014, 0, 31)
4055
- * )
4056
- * //=> 8
4057
- */
4058
- function differenceInCalendarMonths(laterDate, earlierDate, options) {
4059
- const [laterDate_, earlierDate_] = normalizeDates(options?.in, laterDate, earlierDate);
4060
- const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();
4061
- const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();
4062
- return yearsDiff * 12 + monthsDiff;
4063
- }
4064
-
4065
- //#endregion
4066
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfDay.js
4067
- /**
4068
- * The {@link endOfDay} function options.
4059
+ * The unit used to format the distance in {@link formatDistanceStrict}.
4069
4060
  */
4070
4061
  /**
4071
- * @name endOfDay
4072
- * @category Day Helpers
4073
- * @summary Return the end of a day for the given date.
4074
- *
4075
- * @description
4076
- * Return the end of a day for the given date.
4077
- * The result will be in the local timezone.
4078
- *
4079
- * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
4080
- * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
4081
- *
4082
- * @param date - The original date
4083
- * @param options - An object with options
4084
- *
4085
- * @returns The end of a day
4086
- *
4087
- * @example
4088
- * // The end of a day for 2 September 2014 11:55:00:
4089
- * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
4090
- * //=> Tue Sep 02 2014 23:59:59.999
4091
- */
4092
- function endOfDay(date, options) {
4093
- const _date = toDate(date, options?.in);
4094
- _date.setHours(23, 59, 59, 999);
4095
- return _date;
4096
- }
4097
-
4098
- //#endregion
4099
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/endOfMonth.js
4100
- /**
4101
- * The {@link endOfMonth} function options.
4102
- */
4103
- /**
4104
- * @name endOfMonth
4105
- * @category Month Helpers
4106
- * @summary Return the end of a month for the given date.
4107
- *
4108
- * @description
4109
- * Return the end of a month for the given date.
4110
- * The result will be in the local timezone.
4111
- *
4112
- * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
4113
- * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
4114
- *
4115
- * @param date - The original date
4116
- * @param options - An object with options
4117
- *
4118
- * @returns The end of a month
4119
- *
4120
- * @example
4121
- * // The end of a month for 2 September 2014 11:55:00:
4122
- * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
4123
- * //=> Tue Sep 30 2014 23:59:59.999
4124
- */
4125
- function endOfMonth(date, options) {
4126
- const _date = toDate(date, options?.in);
4127
- const month = _date.getMonth();
4128
- _date.setFullYear(_date.getFullYear(), month + 1, 0);
4129
- _date.setHours(23, 59, 59, 999);
4130
- return _date;
4131
- }
4132
-
4133
- //#endregion
4134
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/isLastDayOfMonth.js
4135
- /**
4136
- * @name isLastDayOfMonth
4137
- * @category Month Helpers
4138
- * @summary Is the given date the last day of a month?
4139
- *
4140
- * @description
4141
- * Is the given date the last day of a month?
4142
- *
4143
- * @param date - The date to check
4144
- * @param options - An object with options
4145
- *
4146
- * @returns The date is the last day of a month
4147
- *
4148
- * @example
4149
- * // Is 28 February 2014 the last day of a month?
4150
- * const result = isLastDayOfMonth(new Date(2014, 1, 28))
4151
- * //=> true
4152
- */
4153
- function isLastDayOfMonth(date, options) {
4154
- const _date = toDate(date, options?.in);
4155
- return +endOfDay(_date, options) === +endOfMonth(_date, options);
4156
- }
4157
-
4158
- //#endregion
4159
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInMonths.js
4160
- /**
4161
- * The {@link differenceInMonths} function options.
4162
- */
4163
- /**
4164
- * @name differenceInMonths
4165
- * @category Month Helpers
4166
- * @summary Get the number of full months between the given dates.
4167
- *
4168
- * @param laterDate - The later date
4169
- * @param earlierDate - The earlier date
4170
- * @param options - An object with options
4171
- *
4172
- * @returns The number of full months
4173
- *
4174
- * @example
4175
- * // How many full months are between 31 January 2014 and 1 September 2014?
4176
- * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
4177
- * //=> 7
4178
- */
4179
- function differenceInMonths(laterDate, earlierDate, options) {
4180
- const [laterDate_, workingLaterDate, earlierDate_] = normalizeDates(options?.in, laterDate, laterDate, earlierDate);
4181
- const sign = compareAsc(workingLaterDate, earlierDate_);
4182
- const difference = Math.abs(differenceInCalendarMonths(workingLaterDate, earlierDate_));
4183
- if (difference < 1) return 0;
4184
- if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27) workingLaterDate.setDate(30);
4185
- workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference);
4186
- let isLastMonthNotFull = compareAsc(workingLaterDate, earlierDate_) === -sign;
4187
- if (isLastDayOfMonth(laterDate_) && difference === 1 && compareAsc(laterDate_, earlierDate_) === 1) isLastMonthNotFull = false;
4188
- const result = sign * (difference - +isLastMonthNotFull);
4189
- return result === 0 ? 0 : result;
4190
- }
4191
-
4192
- //#endregion
4193
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getRoundingMethod.js
4194
- function getRoundingMethod(method) {
4195
- return (number) => {
4196
- const result = (method ? Math[method] : Math.trunc)(number);
4197
- return result === 0 ? 0 : result;
4198
- };
4199
- }
4200
-
4201
- //#endregion
4202
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInMilliseconds.js
4203
- /**
4204
- * @name differenceInMilliseconds
4205
- * @category Millisecond Helpers
4206
- * @summary Get the number of milliseconds between the given dates.
4207
- *
4208
- * @description
4209
- * Get the number of milliseconds between the given dates.
4210
- *
4211
- * @param laterDate - The later date
4212
- * @param earlierDate - The earlier date
4213
- *
4214
- * @returns The number of milliseconds
4215
- *
4216
- * @example
4217
- * // How many milliseconds are between
4218
- * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
4219
- * const result = differenceInMilliseconds(
4220
- * new Date(2014, 6, 2, 12, 30, 21, 700),
4221
- * new Date(2014, 6, 2, 12, 30, 20, 600)
4222
- * )
4223
- * //=> 1100
4224
- */
4225
- function differenceInMilliseconds(laterDate, earlierDate) {
4226
- return +toDate(laterDate) - +toDate(earlierDate);
4227
- }
4228
-
4229
- //#endregion
4230
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInSeconds.js
4231
- /**
4232
- * The {@link differenceInSeconds} function options.
4233
- */
4234
- /**
4235
- * @name differenceInSeconds
4236
- * @category Second Helpers
4237
- * @summary Get the number of seconds between the given dates.
4238
- *
4239
- * @description
4240
- * Get the number of seconds between the given dates.
4241
- *
4242
- * @param laterDate - The later date
4243
- * @param earlierDate - The earlier date
4244
- * @param options - An object with options.
4245
- *
4246
- * @returns The number of seconds
4247
- *
4248
- * @example
4249
- * // How many seconds are between
4250
- * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?
4251
- * const result = differenceInSeconds(
4252
- * new Date(2014, 6, 2, 12, 30, 20, 0),
4253
- * new Date(2014, 6, 2, 12, 30, 7, 999)
4254
- * )
4255
- * //=> 12
4256
- */
4257
- function differenceInSeconds(laterDate, earlierDate, options) {
4258
- const diff = differenceInMilliseconds(laterDate, earlierDate) / 1e3;
4259
- return getRoundingMethod(options?.roundingMethod)(diff);
4260
- }
4261
-
4262
- //#endregion
4263
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/formatDistance.js
4264
- /**
4265
- * The {@link formatDistance} function options.
4266
- */
4267
- /**
4268
- * @name formatDistance
4062
+ * @name formatDistanceStrict
4269
4063
  * @category Common Helpers
4270
4064
  * @summary Return the distance between the given dates in words.
4271
4065
  *
4272
4066
  * @description
4273
- * Return the distance between the given dates in words.
4067
+ * Return the distance between the given dates in words, using strict units.
4068
+ * This is like `formatDistance`, but does not use helpers like 'almost', 'over',
4069
+ * 'less than' and the like.
4274
4070
  *
4275
- * | Distance between dates | Result |
4276
- * |-------------------------------------------------------------------|---------------------|
4277
- * | 0 ... 30 secs | less than a minute |
4278
- * | 30 secs ... 1 min 30 secs | 1 minute |
4279
- * | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
4280
- * | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
4281
- * | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
4282
- * | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
4283
- * | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
4284
- * | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
4285
- * | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
4286
- * | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
4287
- * | 1 yr ... 1 yr 3 months | about 1 year |
4288
- * | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
4289
- * | 1 yr 9 months ... 2 yrs | almost 2 years |
4290
- * | N yrs ... N yrs 3 months | about N years |
4291
- * | N yrs 3 months ... N yrs 9 months | over N years |
4292
- * | N yrs 9 months ... N+1 yrs | almost N+1 years |
4293
- *
4294
- * With `options.includeSeconds == true`:
4295
- * | Distance between dates | Result |
4296
- * |------------------------|----------------------|
4297
- * | 0 secs ... 5 secs | less than 5 seconds |
4298
- * | 5 secs ... 10 secs | less than 10 seconds |
4299
- * | 10 secs ... 20 secs | less than 20 seconds |
4300
- * | 20 secs ... 40 secs | half a minute |
4301
- * | 40 secs ... 60 secs | less than a minute |
4302
- * | 60 secs ... 90 secs | 1 minute |
4071
+ * | Distance between dates | Result |
4072
+ * |------------------------|---------------------|
4073
+ * | 0 ... 59 secs | [0..59] seconds |
4074
+ * | 1 ... 59 mins | [1..59] minutes |
4075
+ * | 1 ... 23 hrs | [1..23] hours |
4076
+ * | 1 ... 29 days | [1..29] days |
4077
+ * | 1 ... 11 months | [1..11] months |
4078
+ * | 1 ... N years | [1..N] years |
4303
4079
  *
4304
4080
  * @param laterDate - The date
4305
4081
  * @param earlierDate - The date to compare with
@@ -4309,43 +4085,59 @@ function differenceInSeconds(laterDate, earlierDate, options) {
4309
4085
  *
4310
4086
  * @throws `date` must not be Invalid Date
4311
4087
  * @throws `baseDate` must not be Invalid Date
4088
+ * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
4312
4089
  * @throws `options.locale` must contain `formatDistance` property
4313
4090
  *
4314
4091
  * @example
4315
4092
  * // What is the distance between 2 July 2014 and 1 January 2015?
4316
- * const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
4093
+ * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
4317
4094
  * //=> '6 months'
4318
4095
  *
4319
4096
  * @example
4320
4097
  * // What is the distance between 1 January 2015 00:00:15
4321
- * // and 1 January 2015 00:00:00, including seconds?
4322
- * const result = formatDistance(
4098
+ * // and 1 January 2015 00:00:00?
4099
+ * const result = formatDistanceStrict(
4323
4100
  * new Date(2015, 0, 1, 0, 0, 15),
4324
- * new Date(2015, 0, 1, 0, 0, 0),
4325
- * { includeSeconds: true }
4101
+ * new Date(2015, 0, 1, 0, 0, 0)
4326
4102
  * )
4327
- * //=> 'less than 20 seconds'
4103
+ * //=> '15 seconds'
4328
4104
  *
4329
4105
  * @example
4330
4106
  * // What is the distance from 1 January 2016
4331
4107
  * // to 1 January 2015, with a suffix?
4332
- * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
4108
+ * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
4333
4109
  * addSuffix: true
4334
4110
  * })
4335
- * //=> 'about 1 year ago'
4111
+ * //=> '1 year ago'
4112
+ *
4113
+ * @example
4114
+ * // What is the distance from 1 January 2016
4115
+ * // to 1 January 2015, in minutes?
4116
+ * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
4117
+ * unit: 'minute'
4118
+ * })
4119
+ * //=> '525600 minutes'
4120
+ *
4121
+ * @example
4122
+ * // What is the distance from 1 January 2015
4123
+ * // to 28 January 2015, in months, rounded up?
4124
+ * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
4125
+ * unit: 'month',
4126
+ * roundingMethod: 'ceil'
4127
+ * })
4128
+ * //=> '1 month'
4336
4129
  *
4337
4130
  * @example
4338
4131
  * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
4339
4132
  * import { eoLocale } from 'date-fns/locale/eo'
4340
- * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
4133
+ * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
4341
4134
  * locale: eoLocale
4342
4135
  * })
4343
- * //=> 'pli ol 1 jaro'
4136
+ * //=> '1 jaro'
4344
4137
  */
4345
- function formatDistance(laterDate, earlierDate, options) {
4138
+ function formatDistanceStrict(laterDate, earlierDate, options) {
4346
4139
  const defaultOptions$1 = getDefaultOptions();
4347
4140
  const locale = options?.locale ?? defaultOptions$1.locale ?? enUS;
4348
- const minutesInAlmostTwoDays = 2520;
4349
4141
  const comparison = compareAsc(laterDate, earlierDate);
4350
4142
  if (isNaN(comparison)) throw new RangeError("Invalid time value");
4351
4143
  const localizeOptions = Object.assign({}, options, {
@@ -4353,41 +4145,37 @@ function formatDistance(laterDate, earlierDate, options) {
4353
4145
  comparison
4354
4146
  });
4355
4147
  const [laterDate_, earlierDate_] = normalizeDates(options?.in, ...comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]);
4356
- const seconds = differenceInSeconds(earlierDate_, laterDate_);
4357
- const offsetInSeconds = (getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_)) / 1e3;
4358
- const minutes = Math.round((seconds - offsetInSeconds) / 60);
4359
- let months;
4360
- if (minutes < 2) if (options?.includeSeconds) if (seconds < 5) return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
4361
- else if (seconds < 10) return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
4362
- else if (seconds < 20) return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
4363
- else if (seconds < 40) return locale.formatDistance("halfAMinute", 0, localizeOptions);
4364
- else if (seconds < 60) return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
4365
- else return locale.formatDistance("xMinutes", 1, localizeOptions);
4366
- else if (minutes === 0) return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
4367
- else return locale.formatDistance("xMinutes", minutes, localizeOptions);
4368
- else if (minutes < 45) return locale.formatDistance("xMinutes", minutes, localizeOptions);
4369
- else if (minutes < 90) return locale.formatDistance("aboutXHours", 1, localizeOptions);
4370
- else if (minutes < minutesInDay) {
4371
- const hours = Math.round(minutes / 60);
4372
- return locale.formatDistance("aboutXHours", hours, localizeOptions);
4373
- } else if (minutes < minutesInAlmostTwoDays) return locale.formatDistance("xDays", 1, localizeOptions);
4374
- else if (minutes < minutesInMonth) {
4375
- const days = Math.round(minutes / minutesInDay);
4148
+ const roundingMethod = getRoundingMethod(options?.roundingMethod ?? "round");
4149
+ const milliseconds = earlierDate_.getTime() - laterDate_.getTime();
4150
+ const minutes = milliseconds / millisecondsInMinute;
4151
+ const dstNormalizedMinutes = (milliseconds - (getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_))) / millisecondsInMinute;
4152
+ const defaultUnit = options?.unit;
4153
+ let unit;
4154
+ if (!defaultUnit) if (minutes < 1) unit = "second";
4155
+ else if (minutes < 60) unit = "minute";
4156
+ else if (minutes < minutesInDay) unit = "hour";
4157
+ else if (dstNormalizedMinutes < minutesInMonth) unit = "day";
4158
+ else if (dstNormalizedMinutes < minutesInYear) unit = "month";
4159
+ else unit = "year";
4160
+ else unit = defaultUnit;
4161
+ if (unit === "second") {
4162
+ const seconds = roundingMethod(milliseconds / 1e3);
4163
+ return locale.formatDistance("xSeconds", seconds, localizeOptions);
4164
+ } else if (unit === "minute") {
4165
+ const roundedMinutes = roundingMethod(minutes);
4166
+ return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions);
4167
+ } else if (unit === "hour") {
4168
+ const hours = roundingMethod(minutes / 60);
4169
+ return locale.formatDistance("xHours", hours, localizeOptions);
4170
+ } else if (unit === "day") {
4171
+ const days = roundingMethod(dstNormalizedMinutes / minutesInDay);
4376
4172
  return locale.formatDistance("xDays", days, localizeOptions);
4377
- } else if (minutes < minutesInMonth * 2) {
4378
- months = Math.round(minutes / minutesInMonth);
4379
- return locale.formatDistance("aboutXMonths", months, localizeOptions);
4380
- }
4381
- months = differenceInMonths(earlierDate_, laterDate_);
4382
- if (months < 12) {
4383
- const nearestMonth = Math.round(minutes / minutesInMonth);
4384
- return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
4173
+ } else if (unit === "month") {
4174
+ const months = roundingMethod(dstNormalizedMinutes / minutesInMonth);
4175
+ return months === 12 && defaultUnit !== "month" ? locale.formatDistance("xYears", 1, localizeOptions) : locale.formatDistance("xMonths", months, localizeOptions);
4385
4176
  } else {
4386
- const monthsSinceStartOfYear = months % 12;
4387
- const years = Math.trunc(months / 12);
4388
- if (monthsSinceStartOfYear < 3) return locale.formatDistance("aboutXYears", years, localizeOptions);
4389
- else if (monthsSinceStartOfYear < 9) return locale.formatDistance("overXYears", years, localizeOptions);
4390
- else return locale.formatDistance("almostXYears", years + 1, localizeOptions);
4177
+ const years = roundingMethod(dstNormalizedMinutes / minutesInYear);
4178
+ return locale.formatDistance("xYears", years, localizeOptions);
4391
4179
  }
4392
4180
  }
4393
4181
 
@@ -4419,7 +4207,7 @@ function formatBytes(bytes) {
4419
4207
  }
4420
4208
  function timeAgo(date) {
4421
4209
  if (date === void 0) return "-";
4422
- return formatDistance(date, /* @__PURE__ */ new Date(), { addSuffix: true }).replace("about ", "").replace("less than ", "");
4210
+ return formatDistanceStrict(date, /* @__PURE__ */ new Date(), { addSuffix: true });
4423
4211
  }
4424
4212
  function table(opts) {
4425
4213
  const titles = Object.keys(opts.columns);
@@ -7433,7 +7221,7 @@ const scope = {
7433
7221
 
7434
7222
  //#endregion
7435
7223
  //#region package.json
7436
- var version = "2.5.10";
7224
+ var version = "2.5.12";
7437
7225
 
7438
7226
  //#endregion
7439
7227
  //#region src/error.ts
@@ -14700,4 +14488,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
14700
14488
 
14701
14489
  //#endregion
14702
14490
  export { source_exports as a, init_source as i, StyledError as n, require_cjs as r, app as t };
14703
- //# sourceMappingURL=app-BaAm8oB8.mjs.map
14491
+ //# sourceMappingURL=app-BoBvAhOw.mjs.map