Every factory parses strict ISO 8601 strings by default and throws on malformed input. Importing this plugin enables { loose: true } for untrusted user text, CSV columns, and legacy headers.
Strict parsing stays the default wherever you omit { loose: true }. Importing the plugin never alters existing calls across your codebase.
Returning null on bad data
With loose mode enabled, unreadable strings, empty fields, missing values, and impossible calendar dates like February 30 return null instead of throwing. Form handlers and import scripts can check the result directly without wrapping every field in a try block.
Loose mode only forgives unreadable input data. Passing an unknown time zone like 'Mars/Olympus' is a mistake in application code rather than user input, so it still throws immediately.
Time zones on loose strings
Strings carrying a UTC marker or numeric offset identify a specific moment and convert it into your target or configured zone. Strings without an offset keep the exact date and time written in the text and place them directly in your target zone.
Numeric dates written with slashes, dots, or hyphens default to month-first order. Pass dayFirst: true per call or set it app-wide with configure() for regions that write the day before the month.
Extends core factories and range factories with fallback parsing and null returns on unreadable input. Calling class constructors like new DateTime() with { loose: true } enables fallback parsing while still throwing if the input cannot be read.
Parameters
loosebooleandefault false
Fall back to engine Date parsing and return null when input cannot be read.
dayFirstbooleandefault false
Read numeric dates like '07.09.2026' with the day before the month.
zoneZone
Time zone used to interpret local date-time strings or view instants.
Returns
DateTime | CalendarDate | Time | Duration | null
Parsed instance, or null when input cannot be read.