Skip to content

Commit

Permalink
use i18n for day diff
Browse files Browse the repository at this point in the history
  • Loading branch information
klaustopher committed Dec 11, 2024
1 parent b248f38 commit 3bcc56f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export default class TimeEntryController extends Controller {
} else if (startTimeInMinutes && hoursInMinutes) {
const newEndTime = (startTimeInMinutes + hoursInMinutes) % (24 * 60);

this.endTimeInputTarget.value = `${Math.floor(newEndTime / 60).toString().padStart(2, '0')}:${Math.round(newEndTime % 60).toString().padStart(2, '0')}`;
this.endTimeInputTarget.value = [
Math.floor(newEndTime / 60).toString().padStart(2, '0'),
Math.round(newEndTime % 60).toString().padStart(2, '0'),
].join(':');
}

this.toggleEndTimePlusCaption(startTimeInMinutes, hoursInMinutes);
Expand Down Expand Up @@ -95,7 +98,7 @@ export default class TimeEntryController extends Controller {
const diffInDays = Math.floor((startTimeInMinutes + hoursInMinutes) / (60 * 24));
const span = document.createElement('span');
span.className = 'FormControl-caption';
span.innerText = `+ ${diffInDays} ${diffInDays === 1 ? 'day' : 'days'}`;
span.innerText = `+${diffInDays === 1 ? I18n.t('js.units.day.one') : I18n.t('js.units.day.other', { count: diffInDays })}`;
formControl.append(span);
}
}
Expand Down

0 comments on commit 3bcc56f

Please sign in to comment.