@@ -652,6 +652,22 @@ export const fromDateUnsafe: (date: Date) => Utc = Internal.fromDateUnsafe
652652 */
653653export const makeUnsafe : < A extends DateTime . Input > ( input : A ) => DateTime . PreserveZone < A > = Internal . makeUnsafe
654654
655+ /**
656+ * Creates a `DateTime.Utc` from the number of seconds since the Unix epoch.
657+ *
658+ * **Example** (Creating from epoch seconds)
659+ *
660+ * ```ts import.meta.vitest
661+ * import { DateTime } from "effect"
662+ *
663+ * DateTime.fromEpochSeconds(1704067200).toJSON() // => "2024-01-01T00:00:00.000Z"
664+ * ```
665+ *
666+ * @category constructors
667+ * @since 4.0.0
668+ */
669+ export const fromEpochSeconds : ( seconds : number ) => Utc = Internal . fromEpochSeconds
670+
655671/**
656672 * Create a `DateTime.Zoned` using `DateTime.makeUnsafe` and a time zone.
657673 *
@@ -1600,6 +1616,28 @@ export const zonedOffsetIso: (self: Zoned) => string = Internal.zonedOffsetIso
16001616 */
16011617export const toEpochMillis : ( self : DateTime ) => number = Internal . toEpochMillis
16021618
1619+ /**
1620+ * Converts a `DateTime` to the number of seconds since the Unix epoch.
1621+ *
1622+ * **Details**
1623+ *
1624+ * This returns the UTC timestamp regardless of any time zone information.
1625+ * The result is floored to the nearest second.
1626+ *
1627+ * **Example** (Reading epoch seconds)
1628+ *
1629+ * ```ts import.meta.vitest
1630+ * import { DateTime } from "effect"
1631+ *
1632+ * const dt = DateTime.makeUnsafe("2024-01-01T00:00:00Z")
1633+ * DateTime.toEpochSeconds(dt) // => 1704067200
1634+ * ```
1635+ *
1636+ * @category converting
1637+ * @since 4.0.0
1638+ */
1639+ export const toEpochSeconds : ( self : DateTime ) => number = Internal . toEpochSeconds
1640+
16031641/**
16041642 * Removes the time aspect of a `DateTime`, first adjusting for the time
16051643 * zone. It will return a `DateTime.Utc` only containing the date.
0 commit comments