From eb1029bfc8abb680939426e49a9288b588d9feb9 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 10 Mar 2021 10:20:54 +0100 Subject: [PATCH] feature(lib): locale option for getDateRange --- lib/date.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/date.js b/lib/date.js index e166563b..06aaac13 100644 --- a/lib/date.js +++ b/lib/date.js @@ -36,8 +36,9 @@ export function getLocalTime(t) { return addMinutes(new Date(t), new Date().getTimezoneOffset()); } -export function getDateRange(value) { +export function getDateRange(value, locale) { const now = new Date(); + const localeOptions = dateLocales[locale]; const { num, unit } = value.match(/^(?[0-9]+)(?hour|day|week|month|year)$/).groups; @@ -52,8 +53,8 @@ export function getDateRange(value) { }; case 'week': return { - startDate: startOfWeek(now), - endDate: endOfWeek(now), + startDate: startOfWeek(now, { locale: localeOptions }), + endDate: endOfWeek(now, { locale: localeOptions }), unit: 'day', value, };