0.1.9 #10

Merged
Thilawyn merged 7 commits from next into master 2024-08-20 02:19:32 +02:00
4 changed files with 59 additions and 6 deletions
Showing only changes of commit ad6255b5da - Show all commits

BIN
bun.lockb

Binary file not shown.

View File

@@ -56,15 +56,15 @@
"clean:node": "rm -rf node_modules"
},
"dependencies": {
"remeda": "^2.6.0",
"type-fest": "^4.23.0"
"remeda": "^2.11.0",
"type-fest": "^4.25.0"
},
"devDependencies": {
"bun-types": "^1.1.21",
"npm-check-updates": "^16.14.20",
"bun-types": "^1.1.24",
"npm-check-updates": "^17.0.6",
"npm-sort": "^0.0.4",
"tsup": "^8.2.3",
"tsx": "^4.16.2",
"tsup": "^8.2.4",
"tsx": "^4.17.0",
"typescript": "^5.5.4"
},
"optionalDependencies": {

52
src/Schema/DateTime.ts Normal file
View File

@@ -0,0 +1,52 @@
import { ParseResult, Schema } from "@effect/schema"
import { DateTime } from "effect"
export const DateTimeUtcFromDate = Schema.transformOrFail(
Schema.DateFromSelf,
Schema.DateTimeUtcFromSelf,
{
strict: true,
decode: (date, _, ast) => ParseResult.try({
try: () => DateTime.unsafeMake(date),
catch: e => new ParseResult.Type(
ast,
date,
e instanceof Error ? e.message : undefined,
),
}),
encode: dateTimeUtc => ParseResult.succeed(
DateTime.toDateUtc(dateTimeUtc)
),
},
)
export const DateTimeZonedFromDate = (options: {
readonly timeZone: number | string | DateTime.TimeZone
readonly adjustForTimeZone?: boolean | undefined
}) => Schema.transformOrFail(
Schema.DateFromSelf,
Schema.DateTimeZonedFromSelf,
{
strict: true,
decode: (date, _, ast) => ParseResult.try({
try: () => DateTime.unsafeMakeZoned(date, options),
catch: e => new ParseResult.Type(
ast,
date,
e instanceof Error ? e.message : undefined,
),
}),
encode: dateTime => ParseResult.succeed(
DateTime.toDate(dateTime)
),
},
)

View File

@@ -1,4 +1,5 @@
export * from "./Class"
export * from "./DateTime"
export * from "./Jsonifiable"
export * from "./Kind"
export * as MobX from "./MobX"