Skip to content

Commit

Permalink
Merge branch 'io-1104' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
kbergha committed Jul 19, 2024
2 parents 48acf2c + 2f51fd7 commit 8c5403f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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
11 changes: 6 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 @@ -46,6 +46,7 @@ const OdsDateTime = {
hourCycle: 'h24',
calendar: 'gregory',
timeZone: 'Europe/Oslo',

},
};
dateFromOptions.type = 'from';
Expand All @@ -61,14 +62,14 @@ const OdsDateTime = {
options.localeOptions = { hour: 'numeric', minute: 'numeric', ...options.localeOptions };

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

0 comments on commit 8c5403f

Please sign in to comment.