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
base: main
Are you sure you want to change the base?
Conversation
Hey, I would love to see the support for Buddhist calendar and see your PR merged! |
I would love to see any suggestions regarding to my PR 😀. |
var newDate = cameraDate.withYear(year) | ||
var newDate = if (config.locale.language == Locale("th").language) { | ||
cameraDate.withYear(year - 543) | ||
} else { | ||
cameraDate.withYear(year) | ||
} | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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") | ||
} | ||
} |
There was a problem hiding this comment.
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.
val year = yearsRange.start + it | ||
val year = if (config.locale.language == Locale("th").language) { | ||
(yearsRange.start + it) + 543 | ||
} else { | ||
yearsRange.start + it | ||
} | ||
|
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
I wanted supports for buddhist calendar in Thai. This pull request contains localization and buddhist year supported.