package gs.std.v0.core

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
