sandbox 2.5.10 → 2.5.11

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.
@@ -3155,7 +3155,7 @@ var import_cjs$21 = /* @__PURE__ */ __toESM(require_cjs());
3155
3155
  const timeout = import_cjs$21.option({
3156
3156
  long: "timeout",
3157
3157
  type: Duration,
3158
- description: "The maximum duration a sandbox can run for. Example: 5m, 1h",
3158
+ description: "The maximum duration a sandbox can run for. Example: 5m, 30m",
3159
3159
  defaultValue: () => "5 minutes",
3160
3160
  defaultValueIsSerializable: true
3161
3161
  });
@@ -3240,7 +3240,7 @@ const formatDistanceLocale = {
3240
3240
  other: "almost {{count}} years"
3241
3241
  }
3242
3242
  };
3243
- const formatDistance$1 = (token$1, count, options) => {
3243
+ const formatDistance = (token$1, count, options) => {
3244
3244
  let result;
3245
3245
  const tokenValue = formatDistanceLocale[token$1];
3246
3246
  if (typeof tokenValue === "string") result = tokenValue;
@@ -3762,7 +3762,7 @@ const match = {
3762
3762
  */
3763
3763
  const enUS = {
3764
3764
  code: "en-US",
3765
- formatDistance: formatDistance$1,
3765
+ formatDistance,
3766
3766
  formatLong,
3767
3767
  formatRelative,
3768
3768
  localize,
@@ -3780,6 +3780,15 @@ function getDefaultOptions() {
3780
3780
  return defaultOptions;
3781
3781
  }
3782
3782
 
3783
+ //#endregion
3784
+ //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/_lib/getRoundingMethod.js
3785
+ function getRoundingMethod(method) {
3786
+ return (number) => {
3787
+ const result = (method ? Math[method] : Math.trunc)(number);
3788
+ return result === 0 ? 0 : result;
3789
+ };
3790
+ }
3791
+
3783
3792
  //#endregion
3784
3793
  //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/constants.js
3785
3794
  /**
@@ -3813,6 +3822,18 @@ const daysInYear = 365.2425;
3813
3822
  const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
3814
3823
  /**
3815
3824
  * @constant
3825
+ * @name millisecondsInMinute
3826
+ * @summary Milliseconds in 1 minute
3827
+ */
3828
+ const millisecondsInMinute = 6e4;
3829
+ /**
3830
+ * @constant
3831
+ * @name minutesInYear
3832
+ * @summary Minutes in 1 year.
3833
+ */
3834
+ const minutesInYear = 525600;
3835
+ /**
3836
+ * @constant
3816
3837
  * @name minutesInMonth
3817
3838
  * @summary Minutes in 1 month.
3818
3839
  */
@@ -4029,277 +4050,31 @@ function compareAsc(dateLeft, dateRight) {
4029
4050
  }
4030
4051
 
4031
4052
  //#endregion
4032
- //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/differenceInCalendarMonths.js
4053
+ //#region ../../node_modules/.pnpm/date-fns@4.1.0/node_modules/date-fns/formatDistanceStrict.js
4033
4054
  /**
4034
- * The {@link differenceInCalendarMonths} function options.
4055
+ * The {@link formatDistanceStrict} function options.
4035
4056
  */
4036
4057
  /**
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.
4058
+ * The unit used to format the distance in {@link formatDistanceStrict}.
4069
4059
  */
4070
4060
  /**
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
4061
+ * @name formatDistanceStrict
4269
4062
  * @category Common Helpers
4270
4063
  * @summary Return the distance between the given dates in words.
4271
4064
  *
4272
4065
  * @description
4273
- * Return the distance between the given dates in words.
4066
+ * Return the distance between the given dates in words, using strict units.
4067
+ * This is like `formatDistance`, but does not use helpers like 'almost', 'over',
4068
+ * 'less than' and the like.
4274
4069
  *
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 |
4070
+ * | Distance between dates | Result |
4071
+ * |------------------------|---------------------|
4072
+ * | 0 ... 59 secs | [0..59] seconds |
4073
+ * | 1 ... 59 mins | [1..59] minutes |
4074
+ * | 1 ... 23 hrs | [1..23] hours |
4075
+ * | 1 ... 29 days | [1..29] days |
4076
+ * | 1 ... 11 months | [1..11] months |
4077
+ * | 1 ... N years | [1..N] years |
4303
4078
  *
4304
4079
  * @param laterDate - The date
4305
4080
  * @param earlierDate - The date to compare with
@@ -4309,43 +4084,59 @@ function differenceInSeconds(laterDate, earlierDate, options) {
4309
4084
  *
4310
4085
  * @throws `date` must not be Invalid Date
4311
4086
  * @throws `baseDate` must not be Invalid Date
4087
+ * @throws `options.unit` must be 'second', 'minute', 'hour', 'day', 'month' or 'year'
4312
4088
  * @throws `options.locale` must contain `formatDistance` property
4313
4089
  *
4314
4090
  * @example
4315
4091
  * // 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))
4092
+ * const result = formatDistanceStrict(new Date(2014, 6, 2), new Date(2015, 0, 2))
4317
4093
  * //=> '6 months'
4318
4094
  *
4319
4095
  * @example
4320
4096
  * // 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(
4097
+ * // and 1 January 2015 00:00:00?
4098
+ * const result = formatDistanceStrict(
4323
4099
  * new Date(2015, 0, 1, 0, 0, 15),
4324
- * new Date(2015, 0, 1, 0, 0, 0),
4325
- * { includeSeconds: true }
4100
+ * new Date(2015, 0, 1, 0, 0, 0)
4326
4101
  * )
4327
- * //=> 'less than 20 seconds'
4102
+ * //=> '15 seconds'
4328
4103
  *
4329
4104
  * @example
4330
4105
  * // What is the distance from 1 January 2016
4331
4106
  * // to 1 January 2015, with a suffix?
4332
- * const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
4107
+ * const result = formatDistanceStrict(new Date(2015, 0, 1), new Date(2016, 0, 1), {
4333
4108
  * addSuffix: true
4334
4109
  * })
4335
- * //=> 'about 1 year ago'
4110
+ * //=> '1 year ago'
4111
+ *
4112
+ * @example
4113
+ * // What is the distance from 1 January 2016
4114
+ * // to 1 January 2015, in minutes?
4115
+ * const result = formatDistanceStrict(new Date(2016, 0, 1), new Date(2015, 0, 1), {
4116
+ * unit: 'minute'
4117
+ * })
4118
+ * //=> '525600 minutes'
4119
+ *
4120
+ * @example
4121
+ * // What is the distance from 1 January 2015
4122
+ * // to 28 January 2015, in months, rounded up?
4123
+ * const result = formatDistanceStrict(new Date(2015, 0, 28), new Date(2015, 0, 1), {
4124
+ * unit: 'month',
4125
+ * roundingMethod: 'ceil'
4126
+ * })
4127
+ * //=> '1 month'
4336
4128
  *
4337
4129
  * @example
4338
4130
  * // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
4339
4131
  * import { eoLocale } from 'date-fns/locale/eo'
4340
- * const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
4132
+ * const result = formatDistanceStrict(new Date(2016, 7, 1), new Date(2015, 0, 1), {
4341
4133
  * locale: eoLocale
4342
4134
  * })
4343
- * //=> 'pli ol 1 jaro'
4135
+ * //=> '1 jaro'
4344
4136
  */
4345
- function formatDistance(laterDate, earlierDate, options) {
4137
+ function formatDistanceStrict(laterDate, earlierDate, options) {
4346
4138
  const defaultOptions$1 = getDefaultOptions();
4347
4139
  const locale = options?.locale ?? defaultOptions$1.locale ?? enUS;
4348
- const minutesInAlmostTwoDays = 2520;
4349
4140
  const comparison = compareAsc(laterDate, earlierDate);
4350
4141
  if (isNaN(comparison)) throw new RangeError("Invalid time value");
4351
4142
  const localizeOptions = Object.assign({}, options, {
@@ -4353,41 +4144,37 @@ function formatDistance(laterDate, earlierDate, options) {
4353
4144
  comparison
4354
4145
  });
4355
4146
  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);
4147
+ const roundingMethod = getRoundingMethod(options?.roundingMethod ?? "round");
4148
+ const milliseconds = earlierDate_.getTime() - laterDate_.getTime();
4149
+ const minutes = milliseconds / millisecondsInMinute;
4150
+ const dstNormalizedMinutes = (milliseconds - (getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_))) / millisecondsInMinute;
4151
+ const defaultUnit = options?.unit;
4152
+ let unit;
4153
+ if (!defaultUnit) if (minutes < 1) unit = "second";
4154
+ else if (minutes < 60) unit = "minute";
4155
+ else if (minutes < minutesInDay) unit = "hour";
4156
+ else if (dstNormalizedMinutes < minutesInMonth) unit = "day";
4157
+ else if (dstNormalizedMinutes < minutesInYear) unit = "month";
4158
+ else unit = "year";
4159
+ else unit = defaultUnit;
4160
+ if (unit === "second") {
4161
+ const seconds = roundingMethod(milliseconds / 1e3);
4162
+ return locale.formatDistance("xSeconds", seconds, localizeOptions);
4163
+ } else if (unit === "minute") {
4164
+ const roundedMinutes = roundingMethod(minutes);
4165
+ return locale.formatDistance("xMinutes", roundedMinutes, localizeOptions);
4166
+ } else if (unit === "hour") {
4167
+ const hours = roundingMethod(minutes / 60);
4168
+ return locale.formatDistance("xHours", hours, localizeOptions);
4169
+ } else if (unit === "day") {
4170
+ const days = roundingMethod(dstNormalizedMinutes / minutesInDay);
4376
4171
  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);
4172
+ } else if (unit === "month") {
4173
+ const months = roundingMethod(dstNormalizedMinutes / minutesInMonth);
4174
+ return months === 12 && defaultUnit !== "month" ? locale.formatDistance("xYears", 1, localizeOptions) : locale.formatDistance("xMonths", months, localizeOptions);
4385
4175
  } 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);
4176
+ const years = roundingMethod(dstNormalizedMinutes / minutesInYear);
4177
+ return locale.formatDistance("xYears", years, localizeOptions);
4391
4178
  }
4392
4179
  }
4393
4180
 
@@ -4419,7 +4206,7 @@ function formatBytes(bytes) {
4419
4206
  }
4420
4207
  function timeAgo(date) {
4421
4208
  if (date === void 0) return "-";
4422
- return formatDistance(date, /* @__PURE__ */ new Date(), { addSuffix: true }).replace("about ", "").replace("less than ", "");
4209
+ return formatDistanceStrict(date, /* @__PURE__ */ new Date(), { addSuffix: true });
4423
4210
  }
4424
4211
  function table(opts) {
4425
4212
  const titles = Object.keys(opts.columns);
@@ -7433,7 +7220,7 @@ const scope = {
7433
7220
 
7434
7221
  //#endregion
7435
7222
  //#region package.json
7436
- var version = "2.5.10";
7223
+ var version = "2.5.11";
7437
7224
 
7438
7225
  //#endregion
7439
7226
  //#region src/error.ts
@@ -14700,4 +14487,4 @@ const app = (opts) => (0, import_cjs.subcommands)({
14700
14487
 
14701
14488
  //#endregion
14702
14489
  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
14490
+ //# sourceMappingURL=app-Bq3qWN8p.mjs.map