Skip to content

Commit

Permalink
Merge branch 'main' into io-1340
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaashl committed Nov 8, 2024
2 parents e1a06c4 + c586b79 commit 15d88ab
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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 Oslo kommunes writing rules.

### Added

- Added missing developer tab for date and time.

## [2.0.0] - 2024-05-23

Expand Down
8 changes: 8 additions & 0 deletions src/general/helpers/date_and_time/date_and_time.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ <h2 class="ods-infobox__heading">Important</h2>
</div>
</div>
</div>

<div class="ods-devtools-devmode">
<div class="ods-grid">
<div class="ods-grid__column--12">
<div id="testcases"></div>
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions src/general/helpers/date_and_time/date_and_time.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/general/helpers/date_and_time/date_and_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ const OdsDateTime = {
options.localeOptions = { hour: 'numeric', minute: 'numeric', ...options.localeOptions };

if (options.type === 'to' && typeof options.prefix === 'undefined') {
options.prefix = '&mdash;';
options.prefix = '&ndash;';
}
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 = '&mdash;';
options.prefix = '&ndash;';
}
break;
case 'daytime':
Expand All @@ -78,10 +78,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 = '&mdash;';
options.prefix = '&ndash;';
}
}
});
Expand Down

0 comments on commit 15d88ab

Please sign in to comment.