typst-community / valkyrie

Type safe type safety for Typst
Other
30 stars 3 forks source link

Inconsistency between parsing and coercions for datetimes #8

Open m-haug opened 4 months ago

m-haug commented 4 months ago

Firstly, thank you for the package; it seems to be a great help to package authors.

However, I encountered an issue when using coercions with datetime objects. The date schema function accepts any datetime object (even time only), while the coercion only works for actual dates, without a time component. I think it would be best to split this into three different types, according to the amount of precision: dates, times, and datetimes. Then each of those could have separate schema and coercion functions.

What do you think?

jamesrswift commented 4 months ago

That sounds like a good suggestion. I haven't had a chance to think too deeply on this yet, but my first impression is that it would make sense to focus on the coercions; to have a coercion for dates, times, and date times. It would also make sense to introduce some method of composing coercions.

When I finish work, I'll try some different solutions out and put them here, to see which you think is most intuitive/useful/customizable.