Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Formatter throws variable length error #573

Open
Labels
@chrisjenx

Description

Process: horse.haynet.debug, PID: 10367
java.lang.IllegalArgumentException: At most one variable-length numeric field in a row is allowed, but got several: [year, hourOfAmPm]. Parsing is undefined: for example, with variable-length month number and variable-length day of month, '111' can be parsed as Jan 11th or Nov 1st.
	at kotlinx.datetime.internal.format.parser.NumberSpanParserOperation.<init>(ParserOperation.kt:56)
	at kotlinx.datetime.internal.format.parser.ParserKt.concat$simplify(Parser.kt:69)
	at kotlinx.datetime.internal.format.parser.ParserKt.concat$simplify(Parser.kt:76)
	at kotlinx.datetime.internal.format.parser.ParserKt.concat(Parser.kt:125)
	at kotlinx.datetime.internal.format.ConcatenatedFormatStructure.parser(FormatStructure.kt:233)
	at kotlinx.datetime.internal.format.CachedFormatStructure.<init>(FormatStructure.kt:248)
	at kotlinx.datetime.format.AbstractDateTimeFormatBuilder.build(DateTimeFormatBuilder.kt:476)
	at kotlinx.datetime.format.DateTimeComponents$Companion.Format(DateTimeComponents.kt:59)

Example formatter:

format(
 format = DateTimeComponents.Format {
 monthName(MonthNames.ENGLISH_ABBREVIATED)
 chars(" ")
 day(Padding.NONE)
 chars(" ")
 year(Padding.ZERO)
 amPmHour(Padding.NONE)
 minute();
 amPmMarker("am", "pm")
 },

AFAIK, this is incorrect, or the error is wrong at minimum? As there are two variable lengths, day of month and amPmHour (as they are padding none), but year (should) expects 4 digits not 2-4.

Also in a formatting situation, I don't care about parsing, I'm formatting, so it would be really nice to skip the parser check when I'm only outputting. If parsing that date, 100% agree could potentially be wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /