use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class Utils method convertAlldayUtcToLocal.
/**
* Convert given UTC time into current local time. This assumes it is for an
* allday event and will adjust the time to be on a midnight boundary.
*
* @param recycle Time object to recycle, otherwise null.
* @param utcTime Time to convert, in UTC.
* @param tz The time zone to convert this time to.
*/
public static long convertAlldayUtcToLocal(Time recycle, long utcTime, String tz) {
if (recycle == null) {
recycle = new Time();
}
recycle.setTimezone(Time.TIMEZONE_UTC);
recycle.set(utcTime);
recycle.setTimezone(tz);
return recycle.normalize();
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class Utils method getDisplayedTimezone.
/**
* Returns the timezone to display in the event info, if the local timezone is different
* from the event timezone. Otherwise returns null.
*/
public static String getDisplayedTimezone(long startMillis, String localTimezone, String eventTimezone) {
String tzDisplay = null;
if (!TextUtils.equals(localTimezone, eventTimezone)) {
// Figure out if this is in DST
TimeZone tz = TimeZone.getTimeZone(localTimezone);
if (tz == null || tz.getID().equals("GMT")) {
tzDisplay = localTimezone;
} else {
Time startTime = new Time(localTimezone);
startTime.set(startMillis);
tzDisplay = tz.getDisplayName(false, TimeZone.SHORT);
}
}
return tzDisplay;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class Utils method getWeekNumberFromTime.
/**
* Given a context and a time in millis since unix epoch figures out the
* correct week of the year for that time.
*
* @param millisSinceEpoch
* @return
*/
public static int getWeekNumberFromTime(long millisSinceEpoch, Context context) {
Time weekTime = new Time(getTimeZone(context, null));
weekTime.set(millisSinceEpoch);
weekTime.normalize();
int firstDayOfWeek = getFirstDayOfWeek(context);
// week
if (weekTime.getWeekDay() == Time.SUNDAY && (firstDayOfWeek == Time.SUNDAY || firstDayOfWeek == Time.SATURDAY)) {
weekTime.setDay(weekTime.getDay() + 1);
weekTime.normalize();
} else if (weekTime.getWeekDay() == Time.SATURDAY && firstDayOfWeek == Time.SATURDAY) {
weekTime.setDay(weekTime.getDay() + 2);
weekTime.normalize();
}
return weekTime.getWeekNumber();
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class Utils method getDisplayedDatetime.
/**
* Returns a string description of the specified time interval.
*/
public static String getDisplayedDatetime(long startMillis, long endMillis, long currentMillis, String localTimezone, boolean allDay, Context context) {
// Configure date/time formatting.
int flagsDate = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
int flagsTime = DateUtils.FORMAT_SHOW_TIME;
if (DateFormat.is24HourFormat(context)) {
flagsTime |= DateUtils.FORMAT_24HOUR;
}
Time currentTime = new Time(localTimezone);
currentTime.set(currentMillis);
Resources resources = context.getResources();
String datetimeString = null;
if (allDay) {
// All day events require special timezone adjustment.
long localStartMillis = convertAlldayUtcToLocal(null, startMillis, localTimezone);
long localEndMillis = convertAlldayUtcToLocal(null, endMillis, localTimezone);
if (singleDayEvent(localStartMillis, localEndMillis, currentTime.getGmtOffset())) {
// If possible, use "Today" or "Tomorrow" instead of a full date string.
int todayOrTomorrow = isTodayOrTomorrow(context.getResources(), localStartMillis, currentMillis, currentTime.getGmtOffset());
if (TODAY == todayOrTomorrow) {
datetimeString = resources.getString(R.string.today);
} else if (TOMORROW == todayOrTomorrow) {
datetimeString = resources.getString(R.string.tomorrow);
}
}
if (datetimeString == null) {
// For multi-day allday events or single-day all-day events that are not
// today or tomorrow, use framework formatter.
Formatter f = new Formatter(new StringBuilder(50), Locale.getDefault());
datetimeString = DateUtils.formatDateRange(context, f, startMillis, endMillis, flagsDate, Time.TIMEZONE_UTC).toString();
}
} else {
if (singleDayEvent(startMillis, endMillis, currentTime.getGmtOffset())) {
// Format the time.
String timeString = Utils.formatDateRange(context, startMillis, endMillis, flagsTime);
// If possible, use "Today" or "Tomorrow" instead of a full date string.
int todayOrTomorrow = isTodayOrTomorrow(context.getResources(), startMillis, currentMillis, currentTime.getGmtOffset());
if (TODAY == todayOrTomorrow) {
// Example: "Today at 1:00pm - 2:00 pm"
datetimeString = resources.getString(R.string.today_at_time_fmt, timeString);
} else if (TOMORROW == todayOrTomorrow) {
// Example: "Tomorrow at 1:00pm - 2:00 pm"
datetimeString = resources.getString(R.string.tomorrow_at_time_fmt, timeString);
} else {
// Format the full date. Example: "Thursday, April 12, 1:00pm - 2:00pm"
String dateString = Utils.formatDateRange(context, startMillis, endMillis, flagsDate);
datetimeString = resources.getString(R.string.date_time_fmt, dateString, timeString);
}
} else {
// For multiday events, shorten day/month names.
// Example format: "Fri Apr 6, 5:00pm - Sun, Apr 8, 6:00pm"
int flagsDatetime = flagsDate | flagsTime | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_WEEKDAY;
datetimeString = Utils.formatDateRange(context, startMillis, endMillis, flagsDatetime);
}
}
return datetimeString;
}
use of org.jaxdb.www.ddlx_0_5.xLygluGCXAA.$Time in project android_packages_apps_Etar by LineageOS.
the class EditEventActivity method getEventInfoFromIntent.
private EventInfo getEventInfoFromIntent(Bundle icicle) {
EventInfo info = new EventInfo();
long eventId = -1;
Intent intent = getIntent();
Uri data = intent.getData();
if (data != null) {
try {
eventId = Long.parseLong(data.getLastPathSegment());
} catch (NumberFormatException e) {
if (DEBUG) {
Log.d(TAG, "Create new event");
}
}
} else if (icicle != null && icicle.containsKey(BUNDLE_KEY_EVENT_ID)) {
eventId = icicle.getLong(BUNDLE_KEY_EVENT_ID);
}
boolean allDay = intent.getBooleanExtra(EXTRA_EVENT_ALL_DAY, false);
long begin = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, -1);
long end = intent.getLongExtra(EXTRA_EVENT_END_TIME, -1);
if (end != -1) {
info.endTime = new Time();
if (allDay) {
info.endTime.setTimezone(Time.TIMEZONE_UTC);
}
info.endTime.set(end);
}
if (begin != -1) {
info.startTime = new Time();
if (allDay) {
info.startTime.setTimezone(Time.TIMEZONE_UTC);
}
info.startTime.set(begin);
}
info.id = eventId;
info.eventTitle = intent.getStringExtra(Events.TITLE);
info.calendarId = intent.getLongExtra(Events.CALENDAR_ID, -1);
if (allDay) {
info.extraLong = CalendarController.EXTRA_CREATE_ALL_DAY;
} else {
info.extraLong = 0;
}
return info;
}
Aggregations