Skip to content

Commit

Permalink
Update date-fns to v3.0.5
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
thgreasi committed Dec 21, 2023
1 parent 13722d3 commit 5b3a5d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"color": "^3.2.1",
"color-hash": "^1.1.1",
"copy-to-clipboard": "^3.3.2",
"date-fns": "^2.29.3",
"date-fns": "^3.0.5",
"grommet": "~2.18.0",
"hast-util-sanitize": "^3.0.2",
"json-e": "^4.4.3",
Expand Down
18 changes: 10 additions & 8 deletions src/components/Renderer/widgets/DurationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ export const DurationWidget = widgetFactory('Duration', {}, [JsonTypes.object])(
return '';
}
const customInterval: { [key: string]: string } = {};
Object.entries(interval).forEach(([key, value]) => {
if (value != null && value < 10) {
customInterval[key] = `0${value}`;
} else {
customInterval[key] = `${value}`;
for (const [key, value] of Object.entries(interval)) {
if (value == null) {
continue;
}
});
customInterval[key] = value < 10 ? `0${value}` : `${value}`;
}
let durationText = '';
if (!!interval.years) {
durationText += `${customInterval.years}y `;
}
if (!!interval.years || !!interval.months) {
if (durationText.length > 0 || !!interval.months) {
durationText += `${customInterval.months}m `;
}
if (!!interval.years || !!interval.months || !!interval.days) {
if (durationText.length > 0 || !!interval.days) {
durationText += `${customInterval.days}d `;
}
customInterval.hours ??= '00';
customInterval.minutes ??= '00';
customInterval.seconds ??= '00';
durationText += `${customInterval.hours}:${customInterval.minutes}:${customInterval.seconds}`;
return durationText;
}, []);
Expand Down

0 comments on commit 5b3a5d8

Please sign in to comment.