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

(Calendar) Add Thai DateFormat Supports #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cdmochi
Copy link

@cdmochi cdmochi commented May 14, 2023

I wanted supports for buddhist calendar in Thai. This pull request contains localization and buddhist year supported.

@maxkeppeler
Copy link
Owner

Hey, I would love to see the support for Buddhist calendar and see your PR merged!

@cdmochi
Copy link
Author

cdmochi commented May 26, 2023

I would love to see any suggestions regarding to my PR 😀.

Comment on lines -188 to +219
var newDate = cameraDate.withYear(year)
var newDate = if (config.locale.language == Locale("th").language) {
cameraDate.withYear(year - 543)
} else {
cameraDate.withYear(year)
}

Copy link
Owner

Choose a reason for hiding this comment

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

What does that do? Why do you have to check for locale th when clicking a year and why do you reduce the selected year amount with 543 years?

Copy link
Owner

Choose a reason for hiding this comment

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

Should we consider creating a separate utility function within the utils file? I would appreciate your thoughts on this.

Copy link
Author

@cdmochi cdmochi May 28, 2023

Choose a reason for hiding this comment

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

What does that do? Why do you have to check for locale th when clicking a year and why do you reduce the selected year amount with 543 years?

Firstly, the year in calendarView will be shown as Thai Buddhism year format if and only if thai locale is set.
To calculate BE year manually, just add 543 to year to the BC year. You may look for more references here from the link I provided below as well. https://wesak.org.my/calculating-b-e/#:~:text=Thus%20543%20BCE%2C%20the%20year,B%20%3D%20544%20%2B%202021%20%3D%20B.E.

Comment on lines +175 to +184
val cameraDateFormatter = remember(config.locale) {
if (config.locale.language == Locale("th").language) {
DateTimeFormatter
.ofPattern("yyyy")
.withLocale(Locale("th"))
.withChronology(ThaiBuddhistChronology.INSTANCE)
} else {
DateTimeFormatter.ofPattern("yyyy")
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe extract using the correct DateFormatter based on locale to a utils function in the utils file.

Comment on lines -33 to +41
val year = yearsRange.start + it
val year = if (config.locale.language == Locale("th").language) {
(yearsRange.start + it) + 543
} else {
yearsRange.start + it
}

Copy link
Owner

Choose a reason for hiding this comment

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

Should we consider creating a separate utility function within the utils file? I would appreciate your thoughts on this. (Same as the year selection)

Copy link
Author

Choose a reason for hiding this comment

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

I think so, i'll fix it

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.

None yet

2 participants