Skip to content

Add DateTime.toEpochSeconds and fromEpochSeconds - #6909

Merged
tim-smart merged 3 commits into
Effect-TS:mainfrom
AlfGoto:feat/datetime-to-epoch-seconds
Aug 3, 2026
Merged

Add DateTime.toEpochSeconds and fromEpochSeconds#6909
tim-smart merged 3 commits into
Effect-TS:mainfrom
AlfGoto:feat/datetime-to-epoch-seconds

Conversation

@AlfGoto

@AlfGoto AlfGoto commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #6148

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds epoch seconds utilities to DateTime:

  • toEpochSeconds(dt) - converts DateTime to Unix epoch seconds (floored)
  • fromEpochSeconds(seconds) - creates DateTime.Utc from epoch seconds

Mirrors existing toEpochMillis pattern. Includes tests for conversion, flooring, and roundtrip.

Previous PRs #6211 and #6470 existed but weren't merged before v3 feature freeze. This targets v4.

Related

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Related

  • Related Issue #
  • Closes #

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Aug 3, 2026
@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9300f2a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 7.06 KB 7.06 KB 0.00 KB (0.00%)
batching.ts 9.86 KB 9.86 KB 0.00 KB (0.00%)
brand.ts 6.34 KB 6.34 KB 0.00 KB (0.00%)
cache.ts 10.62 KB 10.62 KB 0.00 KB (0.00%)
config.ts 20.60 KB 20.60 KB 0.00 KB (0.00%)
differ.ts 20.20 KB 20.20 KB 0.00 KB (0.00%)
http-client.ts 21.49 KB 21.49 KB 0.00 KB (0.00%)
logger.ts 10.76 KB 10.76 KB 0.00 KB (0.00%)
metric.ts 8.98 KB 8.98 KB 0.00 KB (0.00%)
optic.ts 7.18 KB 7.18 KB 0.00 KB (0.00%)
pubsub.ts 14.90 KB 14.90 KB 0.00 KB (0.00%)
queue.ts 11.58 KB 11.58 KB 0.00 KB (0.00%)
schedule.ts 10.74 KB 10.74 KB 0.00 KB (0.00%)
schema-class.ts 19.14 KB 19.14 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.96 KB 28.96 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.29 KB 25.29 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.30 KB 13.30 KB 0.00 KB (0.00%)
schema-string.ts 10.94 KB 10.94 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.17 KB 15.17 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.94 KB 21.94 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.34 KB 24.34 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.18 KB 19.18 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.01 KB 19.01 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.87 KB 18.87 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.60 KB 22.60 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.52 KB 19.52 KB 0.00 KB (0.00%)
schema.ts 18.41 KB 18.41 KB 0.00 KB (0.00%)
stm.ts 12.54 KB 12.54 KB 0.00 KB (0.00%)
stream.ts 9.80 KB 9.80 KB 0.00 KB (0.00%)

@AlfGoto
AlfGoto marked this pull request as ready for review August 3, 2026 11:21

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

This PR is missing a changeset for the new public API.

Reviewed changes — 3 files, 2 commits adding DateTime.toEpochSeconds and DateTime.fromEpochSeconds.

  • toEpochSeconds: Converts any DateTime to floored Unix epoch seconds, mirroring the existing toEpochMillis.
  • fromEpochSeconds: Creates a DateTime.Utc from epoch seconds, serving as the inverse of toEpochSeconds.
  • Tests: Cover basic conversion, sub-second flooring, and roundtrip.

⚠️ Missing changeset

The PR adds two public API exports (toEpochSeconds and fromEpochSeconds) to the effect package but includes no changeset file. A patch changeset is required for new public API.

Technical details
# Missing changeset

## Affected sites
- `packages/effect/src/DateTime.ts:669``fromEpochSeconds` export
- `packages/effect/src/DateTime.ts:1639``toEpochSeconds` export

## Required outcome
- Add a `.changeset/` file with `"effect": patch` and a brief description of the added functions.

Pullfrog  | Fix it ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — 1 commit adding the changeset requested in the prior review.

  • Changeset added: .changeset/bright-clocks-count.md with "effect": patch describing the two new exports.

The prior review flagged the missing changeset as the sole concern. Commit 9300f2a addresses it. The code, tests, and internals are unchanged from the prior review and passed that review's scrutiny.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@tim-smart
tim-smart merged commit 1c40b28 into Effect-TS:main Aug 3, 2026
15 of 16 checks passed
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

@effect DateTime Get unix timestamp of a Date

2 participants