Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Locale-invariant parsing and formatting #343

Merged
merged 21 commits into from
Feb 27, 2024

Conversation

dkhalanskyjb
Copy link
Collaborator

The same thing as #251 (except for small tidying up here and there), with the commit history rewritten to be more manageable. @ilya-g, does this commit history look ok?

dkhalanskyjb and others added 21 commits February 19, 2024 16:05
Will be useful for representing the state of fractions of second
internally.
Whether the month is formatted as a number or a name, and whether
it's stored in `LocalDate` or `LocalDateTime`, we still say that
this field represents a year.

Each `FieldSpec` instance is a distinct such field.
We need a way to specify "format a month as a name" and
"format a month as a number without padding." The new
`FieldFormatDirective` interface encodes this concept.
`FormatStructure` defines how a thing is parsed and/or formatted.
It encodes a group of `FieldFormatDirective` instances and directs
how they should behave as a collective:
* should they be parsed/output optionally?
* can there be several alternatives during parsing?
* etc.

The intended way to use the format machinery is to specify a
`FormatStructure` instance and obtain a parser or a formatter by
calling `parser()` or `formatter()` on it.

`CachedFormatStructure` can be used as a thin caching wrapper,
ensuring `parser()` and `formatter()` don't get called repeatedly.
The new class is the superinterface of all the receivers exposed
via the format builder DSL.
Also, provide means of parsing and formatting it.
Fixes #39
Fixes #58
Fixes #90
Fixes #128
Fixes #133
Fixes #139
Fixes #211
Fixes #240
Fixes #83
Fixes #276
Copy link
Member

@ilya-g ilya-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, all is clear

core/common/src/format/DateTimeFormat.kt Show resolved Hide resolved
@dkhalanskyjb dkhalanskyjb merged commit 0e15b5c into master Feb 27, 2024
1 check passed
@dkhalanskyjb dkhalanskyjb deleted the locale-invariant-formatting-rewrite branch February 27, 2024 11:05
@Amejonah1200
Copy link

G.O.A.T. 🐐

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants