From 24ee4da3c9e477b24fa01b8dab00356c54c2818d Mon Sep 17 00:00:00 2001 From: Attila Mihaly <60483498+AttilaMihaly@users.noreply.github.com> Date: Thu, 28 Apr 2022 21:52:58 +0000 Subject: [PATCH] Added LocalTime to the SDK. (#114) * Added LocalTime to the SDK. #113 * Fix. #113 * Fix. #113 --- .../sdk/core/src/morphir/sdk/LocalTime.scala | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 morphir/sdk/core/src/morphir/sdk/LocalTime.scala diff --git a/morphir/sdk/core/src/morphir/sdk/LocalTime.scala b/morphir/sdk/core/src/morphir/sdk/LocalTime.scala new file mode 100644 index 00000000..ed4114e8 --- /dev/null +++ b/morphir/sdk/core/src/morphir/sdk/LocalTime.scala @@ -0,0 +1,27 @@ +package morphir.sdk + +import java.time.temporal.ChronoUnit + +object LocalTime { + + type LocalTime = java.time.LocalTime + + def addHours(hours: Basics.Int)(localTime: LocalTime): LocalTime = + localTime.plusHours(hours.toLong) + + def addMinute(minutes: Basics.Int)(localTime: LocalTime): LocalTime = + localTime.plusMinutes(minutes.toLong) + + def addSeconds(seconds: Basics.Int)(localTime: LocalTime): LocalTime = + localTime.plusSeconds(seconds.toLong) + + def diffInHours(localTime1: LocalTime)(localTime2: LocalTime): Basics.Int = + ChronoUnit.HOURS.between(localTime1, localTime2).toInt + + def diffInMinutes(localTime1: LocalTime)(localTime2: LocalTime): Basics.Int = + ChronoUnit.MINUTES.between(localTime1, localTime2).toInt + + def diffInSeconds(localTime1: LocalTime)(localTime2: LocalTime): Basics.Int = + ChronoUnit.SECONDS.between(localTime1, localTime2).toInt + +}