diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d4d892b..7770750e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed all dates to actually adhere to "Keep a changelog". +- Fixed locale formatting for dates to adhere to UKEs writing rules. + +### Added + +- Added missing developer tab for date and time. ### Changed diff --git a/src/general/helpers/date_and_time/date_and_time.html b/src/general/helpers/date_and_time/date_and_time.html index 06f94b838..1cfe5d448 100644 --- a/src/general/helpers/date_and_time/date_and_time.html +++ b/src/general/helpers/date_and_time/date_and_time.html @@ -63,3 +63,11 @@

Important

+ +
+
+
+
+
+
+
diff --git a/src/general/helpers/date_and_time/date_and_time.init.js b/src/general/helpers/date_and_time/date_and_time.init.js index 6b7d0d2a8..5fbfe1759 100644 --- a/src/general/helpers/date_and_time/date_and_time.init.js +++ b/src/general/helpers/date_and_time/date_and_time.init.js @@ -4,6 +4,13 @@ document.addEventListener('DOMContentLoaded', () => { const testCasesElement = document.getElementById('testcases'); if (testCasesElement) { const testCases = [ + { + dateFrom: new Date(2021, 1, 5, 8, 5, 32), + dateTo: null, + dateFromOptions: {}, + dateToOptions: {}, + toString: 'OdsDateTime.format(new Date(2021, 11, 30, 8, 5, 32))', + }, { dateFrom: new Date(2021, 11, 30, 8, 5, 32), dateTo: null, diff --git a/src/general/helpers/date_and_time/date_and_time.js b/src/general/helpers/date_and_time/date_and_time.js index 3529f4c5f..22f0e0bc8 100644 --- a/src/general/helpers/date_and_time/date_and_time.js +++ b/src/general/helpers/date_and_time/date_and_time.js @@ -46,6 +46,7 @@ const OdsDateTime = { hourCycle: 'h24', calendar: 'gregory', timeZone: 'Europe/Oslo', + }, }; dateFromOptions.type = 'from'; @@ -61,14 +62,14 @@ const OdsDateTime = { options.localeOptions = { hour: 'numeric', minute: 'numeric', ...options.localeOptions }; if (options.type === 'to' && typeof options.prefix === 'undefined') { - options.prefix = '—'; + options.prefix = '–'; } break; case 'datetime': - options.localeOptions = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', ...options.localeOptions }; + options.localeOptions = { year: 'numeric', month: '2-digit', day: '2-digit', hour: 'numeric', minute: 'numeric', ...options.localeOptions }; if (options.type === 'to' && options.format === 'time' && typeof options.prefix === 'undefined') { - options.prefix = '—'; + options.prefix = '–'; } break; case 'daytime': @@ -78,10 +79,10 @@ const OdsDateTime = { options.localeOptions = { ...options.localeOptions }; break; default: - options.localeOptions = { year: 'numeric', month: 'numeric', day: 'numeric', ...options.localeOptions }; + options.localeOptions = { year: 'numeric', month: '2-digit', day: '2-digit', ...options.localeOptions }; if (options.type === 'to' && typeof options.prefix === 'undefined') { - options.prefix = '—'; + options.prefix = '–'; } } });