> I think sigils should only ever accept the extended format. Imagine reading ~D[2020-01-03] and then two lines below ~D[20200103]. :)
Sold! Also, technically the sigils support any calendar (ISO and its parser are just used by default), so upon reflection ISO flags don't belong here. And since they are literals, we should approach them from an Elixir-ish code philosophy where explicitness and uniformity are valued. Extended all the way. > My mind is not yet made on the parsing one but I was thinking about an explicit flag :basic | :extended | :ordinal. Basic vs extended is a separate concern from ordinal dates vs calendar dates. Brainstorming some options here, but what about a keyword list? `format: :basic | :extended | :any` with `:any` as default; and `date: :calendar | :ordinal | :any` with `:any` as default? On Thursday, February 4, 2021 at 2:50:49 PM UTC-8 Kip wrote: > From ISO 8601-1:2019(E): > > 5.2.3 Ordinal date > > > 5.2.3.1 Complete representations > > A complete representation of an ordinal date shall be as follows. > > a) Basic format: [year][dayo] EXAMPLE 1 1985102 > > b) Extended format: [year][“-”][dayo] EXAMPLE 2 1985-102 > > If by agreement, expanded representations are used, the formats shall be > as specified below. The interchange parties shall agree on the additional > number of digits in the time scale component year. > > 5.2.3.2 Expanded representations > > In the examples below it has been agreed to expand the time scale > component year with two digits. > > a) Basic format: [±][year(6)][dayo] EXAMPLE 1 +001985102 > > b) Extended format: [±][year(6)][“-”][dayo] EXAMPLE 2 +001985-102 > > On 5 Feb 2021, at 6:45 am, José Valim <[email protected]> wrote: > > > >> I like José's suggesting of supporting a flag, but it gets kind of >> complicated as there are several dimensions here even in our reduced case. >> Dates, times, and datetimes support either basic or extended notations; >> dates and datetimes support calendar dates or ordinal dates; both are >> applicable to any parsing. >> > > Are we 100% sure that ordinal datetimes are part of ISO8601? Kip, can you > please confirm? > > >> If we went with this approach I'd lean towards always accepting either >> form for one of the dimensions, and using flags to the sigil and parsing >> functions to indicate intent for the other. >> > > I am not necessarily worried about sigils because sigils are always > compile-time literals. It is probably fine to enforce a given format there > rather than multiple ones. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "elixir-lang-core" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/elixir-lang-core/CcXpeMQhsmU/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JNeGkCNW_6ic2XkxTkFV3uyMT%2B3EZYJuguhzzZfpOnpQ%40mail.gmail.com > > <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JNeGkCNW_6ic2XkxTkFV3uyMT%2B3EZYJuguhzzZfpOnpQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/cc25af62-5128-4835-ba96-0dd029fac6b7n%40googlegroups.com.
