mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-04-30 09:38:47 +02:00
properly translate months, closes #10
This commit is contained in:
parent
1a98db66ff
commit
cbd896eb4d
@ -7,7 +7,6 @@ import com.simplemobiletools.calendar.models.Event;
|
|||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
import java.text.DateFormatSymbols;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -93,8 +92,7 @@ public class CalendarImpl implements DBHelper.DBOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getMonthName() {
|
private String getMonthName() {
|
||||||
final String[] months = new DateFormatSymbols().getMonths();
|
String month = Formatter.getMonthName(mTargetDate.getMonthOfYear() - 1);
|
||||||
String month = (months[mTargetDate.getMonthOfYear() - 1]);
|
|
||||||
final String targetYear = mTargetDate.toString(YEAR_PATTERN);
|
final String targetYear = mTargetDate.toString(YEAR_PATTERN);
|
||||||
if (!targetYear.equals(new DateTime().toString(YEAR_PATTERN))) {
|
if (!targetYear.equals(new DateTime().toString(YEAR_PATTERN))) {
|
||||||
month += " " + targetYear;
|
month += " " + targetYear;
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
package com.simplemobiletools.calendar;
|
package com.simplemobiletools.calendar;
|
||||||
|
|
||||||
|
import android.text.format.DateFormat;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class Formatter {
|
public class Formatter {
|
||||||
public static final String DAYCODE_PATTERN = "YYMMdd";
|
public static final String DAYCODE_PATTERN = "YYMMdd";
|
||||||
private static final String EVENT_DATE_PATTERN = "MMMM d YYYY";
|
private static final String EVENT_DATE_PATTERN = "d YYYY"; // MMMM doesn't give the proper month name in some languages
|
||||||
private static final String EVENT_TIME_PATTERN = "HH:mm";
|
private static final String EVENT_TIME_PATTERN = "HH:mm";
|
||||||
|
|
||||||
public static String getEventDate(String dayCode) {
|
public static String getEventDate(String dayCode) {
|
||||||
return getDateTimeFromCode(dayCode).toString(EVENT_DATE_PATTERN);
|
final String dayYear = getDateTimeFromCode(dayCode).toString(EVENT_DATE_PATTERN);
|
||||||
|
final int monthIndex = Integer.valueOf(dayCode.substring(2, 4)) - 1;
|
||||||
|
return getMonthName(monthIndex) + " " + dayYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEventDate(DateTime dateTime) {
|
public static String getEventDate(DateTime dateTime) {
|
||||||
return dateTime.toString(EVENT_DATE_PATTERN);
|
final String dayYear = dateTime.toString(EVENT_DATE_PATTERN);
|
||||||
|
return getMonthName(dateTime.getMonthOfYear() - 1) + " " + dayYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getEventTime(DateTime dateTime) {
|
public static String getEventTime(DateTime dateTime) {
|
||||||
@ -55,4 +62,11 @@ public class Formatter {
|
|||||||
public static String getDayCodeFromDateTime(DateTime dateTime) {
|
public static String getDayCodeFromDateTime(DateTime dateTime) {
|
||||||
return dateTime.toDateTime(DateTimeZone.getDefault()).toString(Formatter.DAYCODE_PATTERN);
|
return dateTime.toDateTime(DateTimeZone.getDefault()).toString(Formatter.DAYCODE_PATTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getMonthName(int id) {
|
||||||
|
final Date date = new Date();
|
||||||
|
date.setMonth(id);
|
||||||
|
String month = DateFormat.format("LLLL", date).toString();
|
||||||
|
return month.substring(0, 1).toUpperCase() + month.substring(1).toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import org.joda.time.DateTime;
|
|||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import butterknife.BindDimen;
|
import butterknife.BindDimen;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -64,7 +63,6 @@ public class MainActivity extends SimpleActivity implements Calendar {
|
|||||||
|
|
||||||
final int baseColor = mConfig.getIsDarkTheme() ? Color.WHITE : Color.BLACK;
|
final int baseColor = mConfig.getIsDarkTheme() ? Color.WHITE : Color.BLACK;
|
||||||
mRes = getResources();
|
mRes = getResources();
|
||||||
Locale.setDefault(Locale.ENGLISH);
|
|
||||||
mTextColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA);
|
mTextColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA);
|
||||||
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA);
|
mTextColorWithEvent = Utils.adjustAlpha(mRes.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA);
|
||||||
mWeakTextColor = Utils.adjustAlpha(baseColor, Constants.LOW_ALPHA);
|
mWeakTextColor = Utils.adjustAlpha(baseColor, Constants.LOW_ALPHA);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user