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

com.dadrox.scuttle.time.joda.converters.scala Maven / Gradle / Ivy

The newest version!
package com.dadrox.scuttle.time.joda

import com.dadrox.scuttle.time.{ Duration, Time }
import org.joda.time.{ DateTime => JodaTime, Duration => JodaDuration }

object converters {
    implicit def scuttleTimeToJodaTime(time: Time) = new {
        def asJoda(): JodaTime = conversions.scuttleTimeToJodaTime(time)
    }

    implicit def jodaTimeToScuttleTime(time: JodaTime) = new {
        def asScuttle(): Time = conversions.jodaTimeToScuttleTime(time)
    }

    implicit def scuttleDurationToJodaDuration(duration: Duration) = new {
        def asJoda(): JodaDuration = conversions.scuttleDurationToJodaDuration(duration)
    }

    implicit def jodaDurationToScuttleDuration(duration: JodaDuration) = new {
        def asScuttle(): Duration = conversions.jodaDurationToScuttleDuration(duration)
    }
}

object conversions {
    implicit def scuttleTimeToJodaTime(time: Time) = new JodaTime(time.milliseconds)
    implicit def jodaTimeToScuttleTime(time: JodaTime) = Time.fromMilliseconds(time.getMillis())

    implicit def scuttleDurationToJodaDuration(duration: Duration) = JodaDuration.millis(duration.inMilliseconds)
    implicit def jodaDurationToScuttleDuration(duration: JodaDuration) = Duration.fromMilliseconds(duration.getMillis())
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy