Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add locale support #24

Merged
merged 30 commits into from
Jan 10, 2020
Merged

Add locale support #24

merged 30 commits into from
Jan 10, 2020

Conversation

erikc5000
Copy link
Owner

This PR adds a Locale typealias around the platform locale type. The default locale can be acquired in common code using the defaultLocale() method.

It also adds the concept of a DateTimeTextProvider along with a default implementation on JVM and Darwin platforms, allowing localized text to be supplied for the day of the week, month, era, AM/PM, and time zone names -- provided that it's available. Differences between platforms should be expected. If something about the stock implementation doesn't cut it, you can roll your own DateTimeTextProvider and initialize Island Time with it using the new initialize {} method.

IslandTime.initialize {
    dateTimeTextProvider = MyProvider
}

Localized text can be parsed, though you should be braced for platform differences.

The localized day of the week is also available, so Date.startOfWeek(locale) may assume the week starts on "Sunday" in the United States or "Monday" in Germany.

Minor breaking changes in the API have been introduced surrounding DateTimeParserSettings.

# Conflicts:
#	core/src/commonMain/kotlin/io/islandtime/Date.kt
#	core/src/commonMain/kotlin/io/islandtime/DayOfWeek.kt
#	core/src/commonTest/kotlin/io/islandtime/MonthTest.kt
# Conflicts:
#	core/src/commonMain/kotlin/io/islandtime/parser/internal/Parsers.kt
…lt char instead (similar to ICU4J's backward compatibility)
@erikc5000 erikc5000 added this to the 0.2.0 milestone Jan 7, 2020
@erikc5000 erikc5000 merged commit 1da5bf1 into master Jan 10, 2020
@erikc5000 erikc5000 deleted the locale-support branch January 10, 2020 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant