fix extra space in persian date fix bad date format in persian (#452)

* fix extra space in persian date fix bad date format in persian

* misspelling fixed

* minor fix
This commit is contained in:
freetux 2021-04-02 18:56:57 +04:30 committed by GitHub
parent 95f268ed02
commit e3e97e9e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 12 deletions

View File

@ -1456,7 +1456,7 @@ public class LocaleController {
} }
} else { } else {
if (usePersianCalendar) { if (usePersianCalendar) {
return persianCalendar.getPersianYear() + "" + persianCalendar.getPersianMonthDay(); return persianCalendar.getPersianMonthDay() + " " + persianCalendar.getPersianYear();
} else { } else {
return getInstance().chatFullDate.format(date); return getInstance().chatFullDate.format(date);
} }

View File

@ -417,7 +417,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
/** /**
* Creates a String representation of the given Calendar by applying the rules of this printer to it. * Creates a String representation of the given Calendar by applying the rules of this printer to it.
* *
* @param c the Calender to apply the rules to. * @param c the calendar to apply the rules to.
* @return a String representation of the given Calendar. * @return a String representation of the given Calendar.
*/ */
private String applyRulesToString(final Calendar c) { private String applyRulesToString(final Calendar c) {
@ -425,7 +425,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
} }
/** /**
* Creation method for ne calender instances. * Creation method for ne calendar instances.
* *
* @return a new Calendar instance. * @return a new Calendar instance.
*/ */

View File

@ -694,7 +694,7 @@ public class NekoConfig {
preferences.edit().putBoolean("proxy_auto_switch", proxyAutoSwitch = !proxyAutoSwitch).apply(); preferences.edit().putBoolean("proxy_auto_switch", proxyAutoSwitch = !proxyAutoSwitch).apply();
} }
public static void toggleUsePersianCalender() { public static void toggleUsePersiancalendar() {
preferences.edit().putInt("persian_calendar", usePersianCalendar = usePersianCalendar > 1 ? 1 : 2).apply(); preferences.edit().putInt("persian_calendar", usePersianCalendar = usePersianCalendar > 1 ? 1 : 2).apply();
} }

View File

@ -482,7 +482,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
ActionBarLayout.headerShadowDrawable = NekoConfig.disableAppBarShadow ? null : parentLayout.getResources().getDrawable(R.drawable.header_shadow).mutate(); ActionBarLayout.headerShadowDrawable = NekoConfig.disableAppBarShadow ? null : parentLayout.getResources().getDrawable(R.drawable.header_shadow).mutate();
parentLayout.rebuildAllFragmentViews(true, true); parentLayout.rebuildAllFragmentViews(true, true);
} else if (position == usePersianCalendarRow) { } else if (position == usePersianCalendarRow) {
NekoConfig.toggleUsePersianCalender(); NekoConfig.toggleUsePersiancalendar();
LocaleController.reloadPersianCalendarConfig(); LocaleController.reloadPersianCalendarConfig();
if (view instanceof TextCheckCell) { if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(LocaleController.usePersianCalendar); ((TextCheckCell) view).setChecked(LocaleController.usePersianCalendar);
@ -986,7 +986,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
} else if (position == appBarShadowRow) { } else if (position == appBarShadowRow) {
textCell.setTextAndCheck(LocaleController.getString("DisableAppBarShadow", R.string.DisableAppBarShadow), NekoConfig.disableAppBarShadow, true); textCell.setTextAndCheck(LocaleController.getString("DisableAppBarShadow", R.string.DisableAppBarShadow), NekoConfig.disableAppBarShadow, true);
} else if (position == usePersianCalendarRow) { } else if (position == usePersianCalendarRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("UsePersianCalender", R.string.UsePersianCalender), LocaleController.getString("UsePersianCalenderInfo", R.string.UsePersianCalenderInfo), LocaleController.usePersianCalendar, true, true); textCell.setTextAndValueAndCheck(LocaleController.getString("UsePersiancalendar", R.string.UsePersiancalendar), LocaleController.getString("UsePersiancalendarInfo", R.string.UsePersiancalendarInfo), LocaleController.usePersianCalendar, true, true);
} else if (position == displayPersianCalendarByLatinRow) { } else if (position == displayPersianCalendarByLatinRow) {
textCell.setTextAndCheck(LocaleController.getString("DisplayPersianCalendarByLatin", R.string.DisplayPersianCalendarByLatin), NekoConfig.displayPersianCalendarByLatin, false); textCell.setTextAndCheck(LocaleController.getString("DisplayPersianCalendarByLatin", R.string.DisplayPersianCalendarByLatin), NekoConfig.displayPersianCalendarByLatin, false);
} else if (position == autoPauseVideoRow) { } else if (position == autoPauseVideoRow) {

View File

@ -53,6 +53,14 @@ public class PersianCalendar extends GregorianCalendar {
return this.persianYear; return this.persianYear;
} }
public String getPersianYearName() {
if (NekoConfig.displayPersianCalendarByLatin) {
return getPersianYear() + "";
} else {
return LanguageUtils.getPersianNumbers(String.valueOf(this.persianYear));
}
}
public int getPersianMonth() { public int getPersianMonth() {
return this.persianMonth; return this.persianMonth;
} }
@ -77,6 +85,7 @@ public class PersianCalendar extends GregorianCalendar {
} }
} }
public String getPersianWeekDayName() { public String getPersianWeekDayName() {
switch (get(7)) { switch (get(7)) {
case 1: case 1:
@ -97,17 +106,17 @@ public class PersianCalendar extends GregorianCalendar {
} }
public String getPersianLongDate() { public String getPersianLongDate() {
return getPersianWeekDayName() + " " + getPersianDayName() + " " + getPersianMonthName() + " " + this.persianYear; return getPersianWeekDayName() + " " + getPersianDayName() + " " + getPersianMonthName() + " " + this.persianYear;
} }
public String getPersianNormalDate() { public String getPersianNormalDate() {
return getPersianDayName() + " " + getPersianMonthName() + " " + getPersianDayName(); return getPersianDayName() + " " + getPersianMonthName() + " " + getPersianYearName();
} }
//like 9 شهریور //like 9 شهریور
public String getPersianMonthDay() { public String getPersianMonthDay() {
return getPersianDayName() + " " + getPersianMonthName(); return getPersianDayName() + " " + getPersianMonthName();
} }
public String getPersianLongDateAndTime() { public String getPersianLongDateAndTime() {

View File

@ -5,6 +5,6 @@ public class PersianCalendarConstants {
public static final long MILLIS_OF_A_DAY = 86400000; public static final long MILLIS_OF_A_DAY = 86400000;
public static final long PERSIAN_EPOCH = 1948321; public static final long PERSIAN_EPOCH = 1948321;
public static final String[] persianMonthNames = new String[]{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"}; public static final String[] persianMonthNames = new String[]{"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"};
public static final String[] persianMonthNamesLatin = new String[]{"Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Day", "Bahman", "Esfand"}; public static final String[] persianMonthNamesLatin = new String[]{"Farvardin", "Ordibehesht", "Khordad", "Tir", "Mordad", "Shahrivar", "Mehr", "Aban", "Azar", "Dey", "Bahman", "Esfand"};
public static final String[] persianWeekDays = new String[]{"شنبه", "یک‌شنبه", "دوشنبه", "سه‌شنبه", "چهارشنبه", "پنج‌شنبه", "جمعه"}; public static final String[] persianWeekDays = new String[]{"شنبه", "یک‌شنبه", "دوشنبه", "سه‌شنبه", "چهارشنبه", "پنج‌شنبه", "جمعه"};
} }

View File

@ -225,7 +225,7 @@
<string name="UnpinSticker">Unpin</string> <string name="UnpinSticker">Unpin</string>
<string name="SetPinnedSuffix">(Pinned)</string> <string name="SetPinnedSuffix">(Pinned)</string>
<string name="AppLinkFDroid">F-Droid</string> <string name="AppLinkFDroid">F-Droid</string>
<string name="UsePersianCalender">Use persian calender</string> <string name="UsePersiancalendar">Use persian calendar</string>
<string name="UsePersianCalenderInfo">Display date with Solar Hijri calendar</string> <string name="UsePersiancalendarInfo">Display date with Solar Hijri calendar</string>
<string name="DisplayPersianCalendarByLatin">Display persian calendar by latin characters</string> <string name="DisplayPersianCalendarByLatin">Display persian calendar by latin characters</string>
</resources> </resources>