Skip to content

Commit

Permalink
Fix possible invalid sleep values, fixes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
waicool20 committed Oct 1, 2018
1 parent b2f944c commit e1169a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class SleepTabView {
) {
init {
val sTime = startTime.get().padStart(4, '0').let {
LocalTime.of(it.substring(0, 2).toInt(), it.substring(2, 4).toInt())
val hour = it.substring(0, 2).toInt()
LocalTime.of(if (hour > 23) 0 else hour, it.substring(2, 4).toInt())
}
val eTime = sTime.plusMinutes((length.get() * 60).toLong())

Expand Down
15 changes: 12 additions & 3 deletions src/main/resources/views/tabs/tab-sleep.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
</HBox>
<VBox fx:id="scriptSleepContent" alignment="CENTER">
<children>
<RangeSlider fx:id="scriptSleepRangeSlider" blockIncrement="1.0" highValue="8.0" lowValue="0.0" majorTickUnit="24.0" max="24.0" minWidth="325.0" minorTickCount="48" showTickLabels="true" showTickMarks="true" stylesheets="@../../styles/rangeslider.css" />
<RangeSlider fx:id="scriptSleepRangeSlider" blockIncrement="1.0" highValue="8.0"
lowValue="0.0" majorTickUnit="24.0" max="23.999" minWidth="325.0"
minorTickCount="48" showTickMarks="true"
stylesheets="@../../styles/rangeslider.css"/>
<Label fx:id="scriptSleepTimeLabel" alignment="CENTER" contentDisplay="CENTER" text="00:00 - 23:00" VBox.vgrow="ALWAYS" />
</children>
<padding>
Expand All @@ -70,7 +73,10 @@
</HBox>
<VBox fx:id="expSleepContent" alignment="CENTER">
<children>
<RangeSlider fx:id="expSleepRangeSlider" blockIncrement="1.0" highValue="8.0" lowValue="0.0" majorTickUnit="24.0" max="24.0" minWidth="325.0" minorTickCount="48" showTickLabels="true" showTickMarks="true" stylesheets="@../../styles/rangeslider.css" />
<RangeSlider fx:id="expSleepRangeSlider" blockIncrement="1.0" highValue="8.0"
lowValue="0.0" majorTickUnit="24.0" max="23.999" minWidth="325.0"
minorTickCount="48" showTickMarks="true"
stylesheets="@../../styles/rangeslider.css"/>
<Label fx:id="expSleepTimeLabel" alignment="CENTER" contentDisplay="CENTER" text="00:00 - 23:00" VBox.vgrow="ALWAYS" />
</children>
<padding>
Expand All @@ -96,7 +102,10 @@
</HBox>
<VBox fx:id="sortieSleepContent" alignment="CENTER">
<children>
<RangeSlider fx:id="sortieSleepRangeSlider" blockIncrement="1.0" highValue="8.0" lowValue="0.0" majorTickUnit="24.0" max="24.0" minWidth="325.0" minorTickCount="48" showTickLabels="true" showTickMarks="true" stylesheets="@../../styles/rangeslider.css" />
<RangeSlider fx:id="sortieSleepRangeSlider" blockIncrement="1.0" highValue="8.0"
lowValue="0.0" majorTickUnit="24.0" max="23.999" minWidth="325.0"
minorTickCount="48" showTickMarks="true"
stylesheets="@../../styles/rangeslider.css"/>
<Label fx:id="sortieSleepTimeLabel" alignment="CENTER" contentDisplay="CENTER" text="00:00 - 23:00" VBox.vgrow="ALWAYS" />
</children>
<padding>
Expand Down

0 comments on commit e1169a3

Please sign in to comment.