mirror of
https://github.com/VibedByKaKi/t3-code-android-nightly.git
synced 2026-10-10 20:31:16 +02:00
Prepare Relay production infrastructure for the PlanetScale PS_20 HA topology, upgrade Effect and Alchemy to compatible betas, reconcile migration state, and preserve patched MCP session termination behavior.\n\nCo-authored-by: codex <codex@users.noreply.github.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/**
|
|
* @title Creating and formatting DateTime values
|
|
*
|
|
* Parse incoming date values safely, use Clock-powered current time, and format
|
|
* instants for API payloads or user-facing labels.
|
|
*/
|
|
import { DateTime, Effect, Option } from "effect"
|
|
|
|
Effect.gen(function*() {
|
|
// Use DateTime.now to get the current time from Effect's Clock service.
|
|
// Using the Clock service ensures tests can use the `TestClock` module to
|
|
// control time.
|
|
const now = yield* DateTime.now
|
|
|
|
// Use DateTime.make to parse a date input, such as a user-entered string or a
|
|
// epoch timestamp. It returns an Option depending on whether the input was
|
|
// valid.
|
|
const parsedOption: Option.Option<DateTime.Utc> = DateTime.make("2024-06-15T14:30:00.000Z")
|
|
|
|
// you can then use the Option apis to unwrap the value
|
|
Option.getOrUndefined(parsedOption)
|
|
|
|
// Calendar/date-time math returns a new DateTime value; the original value is
|
|
// immutable.
|
|
const endsAt = now.pipe(DateTime.add({ hours: 2 }))
|
|
|
|
// The DateTime.format* functions can be used to convert a DateTime value to
|
|
// differen formats.
|
|
yield* Effect.log("ISO string:", DateTime.formatIso(endsAt))
|
|
})
|