Skip to content

Commit

Permalink
feat: add timer display option for always hours
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniiriarios committed Jul 31, 2023
1 parent 3f24da3 commit de9d203
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ const formatTimer = (hours: number, format: TimeFormat): string => {
? `0${hoursFloor}`
: hoursFloor.toString();
return `${hoursDisplay}:${minutes}`;
case TimeFormat.AlwaysHours: // 1.5h
return hours.toFixed(2) + 'h';
case TimeFormat.AlwaysMinutes: // 90m
return Math.round(hours * 60) + 'm';
case TimeFormat.HourDecimal: // 1.5h
case TimeFormat.HourDecimal: // 1.5h / 30m
default:
if (hours < 1) return Math.round(hours * 60) + 'm';
return hours.toFixed(2) + 'h';
Expand Down
3 changes: 2 additions & 1 deletion src/timer-pi.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<div class="sdpi-item">
<div class="sdpi-item-label" data-localize>Format</div>
<select class="sdpi-item-value" id="timeFormat" name="timeFormat">
<option value="hourDecimal">1.5hr</option>
<option value="hourDecimal">1.5hr / 30m</option>
<option value="alwaysHours">1.5hr</option>
<option value="alwaysMinutes">90m</option>
<option value="hoursMinutes">1:30</option>
<option value="hoursMinutesPadded">01:30</option>
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export enum HourType {
}

export enum TimeFormat {
HourDecimal = 'hourDecimal', // 1.5h
HourDecimal = 'hourDecimal', // 1.5h / 30m
AlwaysHours = 'alwaysHours', // 1.5h
AlwaysMinutes = 'alwaysMinutes', // 90m
HoursMinutes = 'hoursMinutes', // 1:30
HoursMinutesPadded = 'hoursMinutesPadded', // 01:30
Expand Down

0 comments on commit de9d203

Please sign in to comment.