shelving 1.175.1 → 1.175.3
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 +1 -1
- package/util/duration.d.ts +4 -4
- package/util/duration.js +12 -10
package/package.json
CHANGED
package/util/duration.d.ts
CHANGED
|
@@ -111,10 +111,10 @@ export declare function isToday(target: PossibleDate, current?: PossibleDate, ca
|
|
|
111
111
|
* - Makes a sensible choice about the best time unit to use.
|
|
112
112
|
* - Years will be used for anything 18 months or more, e.g. `in 2 years`
|
|
113
113
|
* - Months will be used for anything 10 weeks or more, e.g. `in 14 months`
|
|
114
|
-
* - Weeks will be used for anything
|
|
115
|
-
* - Days will be used for anything
|
|
116
|
-
* - Hours will be used for anything
|
|
117
|
-
* - Minutes will be used for anything 1
|
|
114
|
+
* - Weeks will be used for anything 10 days or more, e.g. `in 9 weeks`
|
|
115
|
+
* - Days will be used for anything 1 day or more, e.g. `in 13 days`
|
|
116
|
+
* - Hours will be used for anything 1 hour or more, e.g. `in 23 hours`
|
|
117
|
+
* - Minutes will be used for anything 1 minute or more, e.g. `1 minute ago` or `in 59 minutes`
|
|
118
118
|
* - Seconds will be used for anything 1000 milliseconds or more, e.g. `in 59 seconds`
|
|
119
119
|
*/
|
|
120
120
|
export declare function getBestTimeUnit(ms: number): Unit<TimeUnitKey>;
|
package/util/duration.js
CHANGED
|
@@ -155,25 +155,27 @@ export function isToday(target, current, caller = isToday) {
|
|
|
155
155
|
* - Makes a sensible choice about the best time unit to use.
|
|
156
156
|
* - Years will be used for anything 18 months or more, e.g. `in 2 years`
|
|
157
157
|
* - Months will be used for anything 10 weeks or more, e.g. `in 14 months`
|
|
158
|
-
* - Weeks will be used for anything
|
|
159
|
-
* - Days will be used for anything
|
|
160
|
-
* - Hours will be used for anything
|
|
161
|
-
* - Minutes will be used for anything 1
|
|
158
|
+
* - Weeks will be used for anything 10 days or more, e.g. `in 9 weeks`
|
|
159
|
+
* - Days will be used for anything 1 day or more, e.g. `in 13 days`
|
|
160
|
+
* - Hours will be used for anything 1 hour or more, e.g. `in 23 hours`
|
|
161
|
+
* - Minutes will be used for anything 1 minute or more, e.g. `1 minute ago` or `in 59 minutes`
|
|
162
162
|
* - Seconds will be used for anything 1000 milliseconds or more, e.g. `in 59 seconds`
|
|
163
163
|
*/
|
|
164
164
|
export function getBestTimeUnit(ms) {
|
|
165
165
|
const abs = Math.abs(ms);
|
|
166
|
-
if (abs
|
|
166
|
+
if (abs >= 18 * MONTH)
|
|
167
167
|
return TIME_UNITS.require("year");
|
|
168
|
-
if (abs
|
|
168
|
+
if (abs >= 10 * WEEK)
|
|
169
169
|
return TIME_UNITS.require("month");
|
|
170
|
-
if (abs
|
|
170
|
+
if (abs >= 10 * DAY)
|
|
171
|
+
return TIME_UNITS.require("week");
|
|
172
|
+
if (abs >= DAY)
|
|
171
173
|
return TIME_UNITS.require("day");
|
|
172
|
-
if (abs
|
|
174
|
+
if (abs >= HOUR)
|
|
173
175
|
return TIME_UNITS.require("hour");
|
|
174
|
-
if (abs
|
|
176
|
+
if (abs >= MINUTE)
|
|
175
177
|
return TIME_UNITS.require("minute");
|
|
176
|
-
if (abs
|
|
178
|
+
if (abs >= SECOND)
|
|
177
179
|
return TIME_UNITS.require("second");
|
|
178
180
|
return TIME_UNITS.require("millisecond");
|
|
179
181
|
}
|