-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve recipe time input field behaviour
- Loading branch information
1 parent
4e6288f
commit f5a02ba
Showing
8 changed files
with
102 additions
and
86 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
.../main/java/de/lukasneugebauer/nextcloudcookbook/recipe/domain/model/DurationComponents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.lukasneugebauer.nextcloudcookbook.recipe.domain.model | ||
|
||
data class DurationComponents( | ||
val hours: String = "", | ||
val minutes: String = "", | ||
) { | ||
fun toIsoStringOrNull(): String? { | ||
if (hours.isBlank() && minutes.isBlank() || hours == "0" && minutes == "0") return null | ||
return "PT${hours.ifBlank { "0" }}H${minutes.ifBlank { "0" }}M0S" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ain/java/de/lukasneugebauer/nextcloudcookbook/recipe/util/DurationToDurationComponents.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package de.lukasneugebauer.nextcloudcookbook.recipe.util | ||
|
||
import de.lukasneugebauer.nextcloudcookbook.recipe.domain.model.DurationComponents | ||
import java.time.Duration | ||
import kotlin.time.toKotlinDuration | ||
|
||
fun Duration.toDurationComponents(): DurationComponents = this.toKotlinDuration().toComponents { hours, minutes, _, _ -> | ||
return DurationComponents(hours.toString(), minutes.toString()) | ||
} |
Oops, something went wrong.