All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.co.unclealex.days.Time.scala Maven / Gradle / Ivy

The newest version!
package uk.co.unclealex.days

import java.time.LocalTime

case class Time(hours: Int, minutes: Int) {

  def am: Time = {
    if (hours >= 12) {
      copy(hours = hours - 12)
    } else {
      this
    }
  }

  def pm: Time = {
    if (hours < 12) {
      copy(hours = hours + 12)
    } else {
      this
    }
  }

  def toLocalTime: LocalTime = LocalTime.of(hours, minutes)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy