gs-std/src/main/scala/gs/std/v0/CreatedAt.scala

38 lines
848 B
Scala

package gs.std.v0
import java.time.Instant
/**
* Opaque type that represents the instant something was created.
*/
opaque type CreatedAt = Instant
/**
* Opaque type that represents the instant something was created.
*/
object CreatedAt:
/**
* Instantiate a new [[CreatedAt]] from the given `java.time.Instant`.
*
* @param value The value to semantically represent.
* @return The new [[CreatedAt]].
*/
def apply(value: Instant): CreatedAt = value
given CanEqual[CreatedAt, CreatedAt] = CanEqual.derived
given Ordering[CreatedAt] = Ordering[Instant]
extension (createdAt: Instant)
/**
* @return The underlying `java.time.Instant`.
*/
def unwrap(): Instant = createdAt
/**
* @return The underlying `java.time.Instant`.
*/
def toInstant(): Instant = createdAt
end CreatedAt