diff options
| -rw-r--r-- | challenge-100/frankivo/scala/FunTime.scala | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/challenge-100/frankivo/scala/FunTime.scala b/challenge-100/frankivo/scala/FunTime.scala index 0578ea6551..97ae8f09a5 100644 --- a/challenge-100/frankivo/scala/FunTime.scala +++ b/challenge-100/frankivo/scala/FunTime.scala @@ -39,14 +39,16 @@ object FunTime { makeTime(hour, parsed._2)
}
+ def convert(time: String) : String = {
+ if (("(am|pm)$".r findFirstIn time).isDefined)
+ to24H(time)
+ else
+ to12H(time)
+ }
+
def main(args: Array[String]): Unit = {
examples
- .map(e => {
- if (("(am|pm)$".r findFirstIn e).isDefined)
- to24H(e)
- else
- to12H(e)
- })
+ .map(convert)
.foreach(println)
}
}
\ No newline at end of file |
