Skip to content

Commit

Permalink
Added LocalTime to the SDK. (#114)
Browse files Browse the repository at this point in the history
* Added LocalTime to the SDK. #113

* Fix. #113

* Fix. #113
  • Loading branch information
AttilaMihaly authored Apr 28, 2022
1 parent 4a6ab81 commit 24ee4da
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions morphir/sdk/core/src/morphir/sdk/LocalTime.scala
Original file line number Diff line number Diff line change
@@ -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

}

0 comments on commit 24ee4da

Please sign in to comment.