is there a way to parse the iso 8601 week day form...
# kotlinx-datetime
r
is there a way to parse the iso 8601 week day format - i.e. can I want to parse a string such as
2024-w2-1
d
Not at the moment, but we are open to adding this.
We'd like to collect the use cases first, though: is this format just mandated by something your program interacts with, or do you want to somehow use the ISO week number?
r
The use case is a system for work shifts where everyone thinks in terms of weeks, including the external party that integrated with - ironically enough they calculate at 00:00 on the Monday of the given week rather than give the week-number, so they do a lot of roundabout calculations, where I'd (if possible) want to lean on standards
one thing that's particular interesting imo is the one without the day, so e.g.
2024-W19
, which could be considered a period (from Monday-Sunday/Sunday-Saturday, depending on the locale). But translating it into a period looses the semantic meaning of weeks
d
ISO week-based-year has a strange property: the year boundaries are adjusted so that every year consists only of whole weeks. Example: https://pl.kotl.in/--A79fvRe Do you actually want this behavior?
@Rohde Fischer, any updates on this?
r
sorry for the silence, I've been quite offline
to some extent, the current version of my solution is here: https://github.com/rohdef/rfbpa/tree/main/rfweeks/src/commonMain/kotlin/dk/rohdef/rfweeks it has to be noted that it's made with the domain of rfbpa in mind, and not necessarily general purpose (although I try to move it in that general direction). Also note that I make heavy use of the
Either
-monad (which IMO every project should, domain errors should never be exceptions)
from the parsing perspective YearWeek is the most interesting class, because that's the one that deals with all the iffy logic with when week 1 starts and how to map between dates and weeks etc.