Monday 19 September 2022

Offset Date-Time in TOML

OffsetDateTime is a representation of a date-time with an offset. This class stores all date and time fields, to a precision of nanoseconds, as well as the offset from UTC/Greenwich.

 

offsetDateTime1.toml

odt1 = 2022-05-05T09:32:00Z
odt2 = 2022-05-05T09:32:00-07:30
odt3 = 2022-05-05T09:32:00+07:30
odt4 = 2022-05-05T09:32:00.999999-07:00

 

Above snippet is equivalent to following json.

{
  "odt1": "2022-05-05T09:32:00.000Z",
  "odt2": "2022-05-05T17:02:00.000Z",
  "odt3": "2022-05-05T02:02:00.000Z",
  "odt4": "2022-05-05T16:32:00.999Z"
}

 

To improve the readability, you can replace the letter T with a space.

 

offsetDateTime2.toml

odt1 = 2022-05-05 09:32:00Z
odt2 = 2022-05-05 09:32:00-07:30
odt3 = 2022-05-05 09:32:00+07:30
odt4 = 2022-05-05 09:32:00.999999-07:00

 If the milliseconds precision value contains greater precision than the implementation can support, the additional precision must be truncated, not rounded.

 

Previous                                                 Next                                                 Home

No comments:

Post a Comment