@jsenv/humanize 1.8.1 → 1.8.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.
@@ -3072,7 +3072,9 @@ const toLocalDayKey = (date) => {
3072
3072
  * Coerces what `<Time>` accepts as a value — a Date, a ms timestamp, a
3073
3073
  * parseable string — into a Date, or null when it cannot. `parseString`
3074
3074
  * lets a caller claim the string forms it recognizes ("HH:MM" for a
3075
- * time-of-day, "YYYY-MM" for a month…) before the generic ones apply.
3075
+ * time-of-day, "YYYY-MM" for a month…) before the generic ones apply; the
3076
+ * strings it does not claim (it answers null) still go through them, so a
3077
+ * caller shaping one form never has to re-implement ISO parsing.
3076
3078
  */
3077
3079
  const toDate = (value, parseString) => {
3078
3080
  if (value instanceof Date) {
@@ -3083,7 +3085,10 @@ const toDate = (value, parseString) => {
3083
3085
  }
3084
3086
  if (typeof value === "string") {
3085
3087
  if (parseString) {
3086
- return parseString(value);
3088
+ const parsed = parseString(value);
3089
+ if (parsed) {
3090
+ return parsed;
3091
+ }
3087
3092
  }
3088
3093
  // "YYYY-MM-DD" — use local midnight to avoid UTC shift
3089
3094
  if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {