Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

shoooe/hotchocolate-nodatime

Repository files navigation

⚠️ Warning

This repository has been absorbed into Hot Chocolate.

The corresponding Nuget package HotChocolate.Types.NodaTime is now managed by ChilliCream.

See this PR for reference.


Introduction

Adds support for NodaTime types in Hot Chocolate.

Usage

.NET Core

Install the package from NuGet:

dotnet add package HotChocolate.Types.NodaTime

Call AddNodaTime on your schema builder like so:

SchemaBuilder.New()
    // ...
    .AddNodaTime()
    .Create();

Documentation

DateTimeZone

Format: One Zone ID from these

Literal example: "Europe/Rome"

References:

Duration

Literal example: "-123:07:53:10.019"

References:

Instant

Literal example: "2020-02-20T17:42:59Z"

References:

IsoDayOfWeek

Literal example: 7

References:

LocalDate

Literal example: "2020-12-25"

References:

LocalDateTime

Literal example: "2020-12-25T13:46:78"

References:

LocalDateTime

Literal examples:

  • "12:42:13"
  • "12:42:13.03101"

References:

OffsetDateTime

Literal examples:

  • "2020-12-25T13:46:78+02"
  • "2020-12-25T13:46:78+02:35"

References:

OffsetDate

Literal examples:

  • "2020-12-25+02"
  • "2020-12-25+02:35"

References:

OffsetTime

Literal examples:

  • "13:46:78+02"
  • "13:46:78+02:35"

References:

Offset

Literal examples:

  • "+02"
  • "+02:35"

References:

Period

Literal examples:

  • "P-3W3D"
  • "PT139t"
  • "P-3W3DT139t"

References:

ZonedDateTime

There's nothing close to a standard for timezoned date-times. Therefore this library chooses to follow the order of the ZonedDateTime constructor and define a format with a LocalDateTime pattern followed by a timezone ID followed by an offset. Feel free to override this behavior.

Literal examples:

  • "2020-12-31T18:30:13 UTC +00"
  • "2020-12-31T19:40:13 Europe/Rome +01"
  • "2020-12-31T19:40:13 Asia/Kathmandu +05:45"

References: