aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Oosterhuis <frank.oosterhuis@getthere.nl>2021-02-16 11:34:42 +0100
committerFrank Oosterhuis <frank.oosterhuis@getthere.nl>2021-02-16 11:34:42 +0100
commit5e9f6a7f1a0a9da2ac250a53206aca5bc2eb2323 (patch)
tree9bbe5d4a1e44aa5c13bf285045071cbc8ae01dae
parent65ea62571cc749356e227dc27f7dc5116620e360 (diff)
downloadperlweeklychallenge-club-5e9f6a7f1a0a9da2ac250a53206aca5bc2eb2323.tar.gz
perlweeklychallenge-club-5e9f6a7f1a0a9da2ac250a53206aca5bc2eb2323.tar.bz2
perlweeklychallenge-club-5e9f6a7f1a0a9da2ac250a53206aca5bc2eb2323.zip
to12H
-rw-r--r--challenge-100/frankivo/scala/FunTime.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/challenge-100/frankivo/scala/FunTime.scala b/challenge-100/frankivo/scala/FunTime.scala
index 6aa4d83229..0578ea6551 100644
--- a/challenge-100/frankivo/scala/FunTime.scala
+++ b/challenge-100/frankivo/scala/FunTime.scala
@@ -5,9 +5,12 @@ object FunTime {
"08:24am",
"09:39 am",
"08:24",
- "20:24",
- "13:37",
+ "11:59",
+ "12:00",
+ "12:01",
"12:34",
+ "13:37",
+ "20:24",
"18:04"
)
@@ -21,7 +24,12 @@ object FunTime {
}
def to12H(time: String): String = {
- time
+ val parsed = getTime(time)
+
+ val suffix = if (parsed._1 < 12) "am" else "pm"
+ val hour = if (parsed._1 > 12) parsed._1 - 12 else parsed._1
+
+ makeTime(hour, parsed._2, suffix)
}
def to24H(time: String): String = {