configure()
configure(settings?): ActiveSettingsUpdates one or more process-wide defaults and returns a snapshot of the active configuration. Calling it with no arguments reads the current settings without changing them.
Omitted properties keep their current values. Pass null for the time zone or locale to restore the runtime’s local defaults.
import { configure, date, datetime } from 'native-dates';
configure({
zone: 'Europe/Berlin',
locale: 'de-DE',
weekStart: 'sunday',
});
datetime('2026-11-16T17:30:00Z').zone; // 'Europe/Berlin'
date('2026-11-18').startOf('week').toString(); // '2026-11-15'
configure().weekStart; // 7
// Reset back to the runtime time zone, runtime locale, and Monday
configure({ zone: null, locale: null, weekStart: 'monday' });Parameters
Process-wide defaults to update. Omitted keys stay unchanged.
5 options
Default time zone for factories and now(). Pass null to reset to the runtime's local zone.
Default BCP 47 locale tag for format() and text. Pass null to reset to the runtime's locale.
1First day of the week for week boundaries, from 1 for Monday through 7 for Sunday.
falseRead ambiguous numeric dates such as '07.09.2026' day-first with @native-dates/plugins/loose.
Custom names mapped to valid zones, merged into active aliases with @native-dates/plugins/zones.
Returns
A shallow copy of the active settings after applying any updates.
Plugins extend configure() with their own options once imported. Setting a plugin option before importing its plugin throws a RangeError:
import { configure, date, now } from 'native-dates';
import '@native-dates/plugins/loose';
import '@native-dates/plugins/zones';
configure({
dayFirst: true,
zoneAliases: { hq: 'Europe/Berlin' },
});
date('07.09.2026', { loose: true })?.toString(); // '2026-09-07'
now('hq').zone; // 'Europe/Berlin'
configure({ dayFirst: false });