writefreely / writefreely-swift

A Swift package wrapping the WriteFreely / Write.as API
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

Date decoder throws error if instance uses fractional seconds #34

Closed AngeloStavrow closed 2 years ago

AngeloStavrow commented 2 years ago

This is related to writefreely/writefreely-swiftui-multiplatform#200 where, if the WriteFreely instance returns dates with fractional seconds (e.g., 2022-09-28T11:55:39.886581893Z), the date-decoding strategy fails and an error is thrown.

A potential solution has been added in a note to this comment in the Vapor repo.

thebaer commented 2 years ago

Without doing more digging yet, I'm not sure why sub-second datetimes are being stored for these WriteFreely instances. But as mentioned in this SO answer, the Go JSON library will always output times according to RFC3339, with sub-seconds if they're present.

So while we wait for a fix in WF (and for it to be widely deployed), I definitely think the library should be able to handle this behavior, since it still adheres to the standard (although the behavior is undesired).

moredhel commented 2 years ago

I've put together a quick PR for WF, but as you say it will take a while for it to be fully deployed. https://github.com/writefreely/writefreely/pull/585