From f59908855ba13cf2257e0aea3d4d83e270356d69 Mon Sep 17 00:00:00 2001 From: aminography Date: Wed, 29 Dec 2021 12:55:01 +0100 Subject: [PATCH 1/2] Considered timeZone and locale in calendar conversion. --- .../aminography/primecalendar/PrimeCalendar.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/library/src/main/java/com/aminography/primecalendar/PrimeCalendar.kt b/library/src/main/java/com/aminography/primecalendar/PrimeCalendar.kt index e0f9e86..cc86199 100644 --- a/library/src/main/java/com/aminography/primecalendar/PrimeCalendar.kt +++ b/library/src/main/java/com/aminography/primecalendar/PrimeCalendar.kt @@ -521,25 +521,25 @@ abstract class PrimeCalendar( * Returns an instance of [CivilCalendar] which is equivalent to the time of the current calendar. */ fun toCivil(): CivilCalendar = - CivilCalendar().also { it.timeInMillis = timeInMillis } + CivilCalendar(internalCalendar.timeZone, locale).also { it.timeInMillis = timeInMillis } /** * Returns an instance of [PersianCalendar] which is equivalent to the time of the current calendar. */ fun toPersian(): PersianCalendar = - PersianCalendar().also { it.timeInMillis = timeInMillis } + PersianCalendar(internalCalendar.timeZone, locale).also { it.timeInMillis = timeInMillis } /** * Returns an instance of [HijriCalendar] which is equivalent to the time of the current calendar. */ fun toHijri(): HijriCalendar = - HijriCalendar().also { it.timeInMillis = timeInMillis } + HijriCalendar(internalCalendar.timeZone, locale).also { it.timeInMillis = timeInMillis } /** * Returns an instance of [JapaneseCalendar] which is equivalent to the time of the current calendar. */ fun toJapanese(): JapaneseCalendar = - JapaneseCalendar().also { it.timeInMillis = timeInMillis } + JapaneseCalendar(internalCalendar.timeZone, locale).also { it.timeInMillis = timeInMillis } // --------------------------------------------------------------------------------------------- @@ -854,7 +854,14 @@ abstract class PrimeCalendar( } } - private fun checkDisplayNameParams(field: Int, style: Int, minStyle: Int, maxStyle: Int, locale: Locale?, vararg fields: Int): Boolean { + private fun checkDisplayNameParams( + field: Int, + style: Int, + minStyle: Int, + maxStyle: Int, + locale: Locale?, + vararg fields: Int + ): Boolean { if (field < 0 || field >= FIELD_COUNT || style < minStyle || style > maxStyle) { throw IllegalArgumentException() } From 6b24a42f4e8b6b75635dbdf730f952a3ee69119b Mon Sep 17 00:00:00 2001 From: Amin Hassani Date: Wed, 29 Dec 2021 13:01:40 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f0d7c2..fb9a3ff 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Add the following lines to your `build.gradle` file: ```gradle dependencies { - implementation 'com.aminography:primecalendar:1.4.0' + implementation 'com.aminography:primecalendar:1.4.1' } ``` @@ -39,7 +39,7 @@ Add the following lines to your `pom.xml` file: com.aminography primecalendar - 1.4.0 + 1.4.1 ```