-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Tim Smart <tim.smart@arisechurch.com>
- Loading branch information
Showing
7 changed files
with
2,801 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
add DateTime module | ||
|
||
The `DateTime` module provides functionality for working with time, including | ||
support for time zones and daylight saving time. | ||
|
||
It has two main data types: `DateTime.Utc` and `DateTime.Zoned`. | ||
|
||
A `DateTime.Utc` represents a time in Coordinated Universal Time (UTC), and | ||
a `DateTime.Zoned` contains both a UTC timestamp and a time zone. | ||
|
||
There is also a `CurrentTimeZone` service, for setting a time zone contextually. | ||
|
||
```ts | ||
import { DateTime, Effect } from "effect"; | ||
|
||
Effect.gen(function* () { | ||
// Get the current time in the current time zone | ||
const now = yield* DateTime.nowInCurrentZone; | ||
|
||
// Math functions are included | ||
const tomorrow = DateTime.add(now, 1, "day"); | ||
|
||
// Convert to a different time zone | ||
// The UTC portion of the `DateTime` is preserved and only the time zone is | ||
// changed | ||
const sydneyTime = tomorrow.pipe( | ||
DateTime.unsafeSetZoneNamed("Australia/Sydney"), | ||
); | ||
}).pipe(DateTime.withCurrentZoneNamed("America/New_York")); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@effect/schema": patch | ||
--- | ||
|
||
add schemas for working with the DateTime module |
Oops, something went wrong.