package gs.std.v0.core

import java.time.Instant

/** Opaque type that represents the instant something was updated.
  */
opaque type UpdatedAt = Instant

/** Opaque type that represents the instant something was updated.
  */
object UpdatedAt:

  /** Instantiate a new [[UpdatedAt]] from the given `java.time.Instant`.
    *
    * @param value
    *   The value to semantically represent.
    * @return
    *   The new [[UpdatedAt]].
    */
  def apply(value: Instant): UpdatedAt = value

  given CanEqual[UpdatedAt, UpdatedAt] = CanEqual.derived

  given Ordering[UpdatedAt] = Ordering[Instant]

  extension (updatedAt: Instant)
    /** @return
      *   The underlying `java.time.Instant`.
      */
    def unwrap(): Instant = updatedAt

    /** @return
      *   The underlying `java.time.Instant`.
      */
    def toInstant(): Instant = updatedAt

end UpdatedAt
