Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add DateTime module #3296

Merged
merged 61 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
dd2603c
draft: DateTime module
tim-smart Jul 18, 2024
ca36050
current zone apis
tim-smart Jul 18, 2024
6058b02
add maths
tim-smart Jul 19, 2024
96374fe
wip
tim-smart Jul 19, 2024
651b832
startOf / endOf
tim-smart Jul 19, 2024
838fe1a
formatting
tim-smart Jul 19, 2024
8bc462e
wip
tim-smart Jul 19, 2024
f82caaa
rearrange
tim-smart Jul 19, 2024
1585b7c
add instances
tim-smart Jul 19, 2024
1290734
improve parts apis
tim-smart Jul 19, 2024
91f0b83
adjusted apis require DateTime.WithZone
tim-smart Jul 19, 2024
187efc5
reword adjusted jsdocs
tim-smart Jul 19, 2024
da1fd4b
fix docs
tim-smart Jul 19, 2024
a53e6c9
formatIso
tim-smart Jul 19, 2024
98210ff
fix import
tim-smart Jul 19, 2024
a3f7e88
simplify WithZone model
tim-smart Jul 19, 2024
f04a69d
test .endOf with time zones
tim-smart Jul 19, 2024
6171b7c
add CurrentTimeZone layers
tim-smart Jul 19, 2024
34efcee
clean-up
tim-smart Jul 19, 2024
93503d2
handle months with less days in .add
tim-smart Jul 19, 2024
a64d3e2
add order apis
tim-smart Jul 19, 2024
9a78e31
setParts
Jul 20, 2024
f366ac3
DateTimeUtcFromSelf schema
Jul 20, 2024
c98ea79
DateTimeUtcFromNumber
Jul 20, 2024
65df503
add string to input
Jul 20, 2024
5704e2b
move Utc & Zoned to top level
tim-smart Jul 20, 2024
5ca2209
fixes
tim-smart Jul 20, 2024
6e5f422
add some examples
tim-smart Jul 20, 2024
cbd5a84
test decode failure for Zoned
tim-smart Jul 20, 2024
be68b2c
update changesets
tim-smart Jul 20, 2024
f1c8c22
use Clock.currentTimeMillis for now
tim-smart Jul 20, 2024
21ddda7
wip
tim-smart Jul 20, 2024
9103614
support TimeZone in makeZoned
tim-smart Jul 20, 2024
f1300e4
Update packages/effect/src/DateTime.ts
tim-smart Jul 20, 2024
45edabd
rename zoned apis
Jul 20, 2024
758dee3
add inputInTimeZone option
Jul 20, 2024
ea5a8dd
makeZonedFromAdjusted
Jul 21, 2024
ef8eb0f
fix docs
Jul 21, 2024
e5219a7
fix schema
Jul 21, 2024
c1ed071
floorTime apis
tim-smart Jul 21, 2024
7a82583
widen input types for adjusted apis
tim-smart Jul 21, 2024
5687565
use temporal format for zoned strings
tim-smart Jul 21, 2024
9226a8d
fix tests
tim-smart Jul 21, 2024
42347d1
remove schema static annotations
tim-smart Jul 21, 2024
dfc064d
toString & schema tweaks
tim-smart Jul 21, 2024
11b829e
remove periods from schema identifier's
tim-smart Jul 21, 2024
2730053
adjust zonedStringRegex
tim-smart Jul 21, 2024
036bc95
remove Adjusted suffix
tim-smart Jul 21, 2024
9c5f493
docs adjustments
tim-smart Jul 21, 2024
5202aea
adjust formatting apis
tim-smart Jul 22, 2024
009d9de
fix changeset
tim-smart Jul 22, 2024
68f0e04
support converting input with setZone apis
tim-smart Jul 22, 2024
676a1fb
s/inputInTimeZone/adjustForTimeZone
tim-smart Jul 22, 2024
2ad90f7
unsafeIsPast/unsafeIsFuture
tim-smart Jul 22, 2024
4bdd73c
formatIsoDate
tim-smart Jul 22, 2024
12bd55f
fix args predicates
tim-smart Jul 22, 2024
ba2860c
formatLocal
tim-smart Jul 22, 2024
486b458
fixes for ios
tim-smart Jul 25, 2024
bb6f616
support parts for add/subtract
tim-smart Jul 25, 2024
7bd0740
support more units in startOf/endOf
tim-smart Jul 25, 2024
e4871d6
implement DateTime.nearest
tim-smart Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .changeset/clean-trainers-tap.md
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"));
```
5 changes: 5 additions & 0 deletions .changeset/red-bottles-cough.md
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
Loading