@jsenv/humanize 1.8.1 → 1.8.2

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.
@@ -3056,7 +3056,9 @@ const toLocalDayKey = (date) => {
3056
3056
  * Coerces what `<Time>` accepts as a value — a Date, a ms timestamp, a
3057
3057
  * parseable string — into a Date, or null when it cannot. `parseString`
3058
3058
  * lets a caller claim the string forms it recognizes ("HH:MM" for a
3059
- * time-of-day, "YYYY-MM" for a month…) before the generic ones apply.
3059
+ * time-of-day, "YYYY-MM" for a month…) before the generic ones apply; the
3060
+ * strings it does not claim (it answers null) still go through them, so a
3061
+ * caller shaping one form never has to re-implement ISO parsing.
3060
3062
  */
3061
3063
  const toDate = (value, parseString) => {
3062
3064
  if (value instanceof Date) {
@@ -3067,7 +3069,10 @@ const toDate = (value, parseString) => {
3067
3069
  }
3068
3070
  if (typeof value === "string") {
3069
3071
  if (parseString) {
3070
- return parseString(value);
3072
+ const parsed = parseString(value);
3073
+ if (parsed) {
3074
+ return parsed;
3075
+ }
3071
3076
  }
3072
3077
  // "YYYY-MM-DD" — use local midnight to avoid UTC shift
3073
3078
  if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {