/** * Returns just the selection part of the weather query from a normalized today value. * This is used to get a weather forecast from today's date. To make this easy to use * in compound selection, we embed today's date as an argument in the query. * * @return The selection part of the weather query for today onwards */ public static String getSqlSelectForTodayOnwards() { long normalizedUtcNow = SunshineDateUtils.normalizeDate(System.currentTimeMillis()); return WeatherContract.WeatherEntry.COLUMN_DATE + " >= " + normalizedUtcNow; } }
long localDate = getLocalDateFromUTC(dateInMillis); long dayNumber = getDayNumber(localDate); long currentDayNumber = getDayNumber(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (dayNumber - currentDayNumber < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(dateInMillis); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight); long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long startDay = SunshineDateUtils.getNormalizedUtcDateForToday(); date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
/** * Given a day, returns just the name to use for that day. * E.g "today", "tomorrow", "Wednesday". * * @param context Context to use for resource localization * @param dateInMillis The date in milliseconds (local time) * * @return the string day of the week */ private static String getDayName(Context context, long dateInMillis) { /* * If the date is today, return the localized version of "Today" instead of the actual * day name. */ long dayNumber = getDayNumber(dateInMillis); long currentDayNumber = getDayNumber(System.currentTimeMillis()); if (dayNumber == currentDayNumber) { return context.getString(R.string.today); } else if (dayNumber == currentDayNumber + 1) { return context.getString(R.string.tomorrow); } else { /* * Otherwise, if the day is not today, the format is just the day of the week * (e.g "Wednesday") */ SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE"); return dayFormat.format(dateInMillis); } } }
long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight); long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long startDay = SunshineDateUtils.getNormalizedUtcDateForToday(); date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
/** * Given a day, returns just the name to use for that day. * E.g "today", "tomorrow", "Wednesday". * * @param context Context to use for resource localization * @param dateInMillis The date in milliseconds (local time) * * @return the string day of the week */ private static String getDayName(Context context, long dateInMillis) { /* * If the date is today, return the localized version of "Today" instead of the actual * day name. */ long dayNumber = getDayNumber(dateInMillis); long currentDayNumber = getDayNumber(System.currentTimeMillis()); if (dayNumber == currentDayNumber) { return context.getString(R.string.today); } else if (dayNumber == currentDayNumber + 1) { return context.getString(R.string.tomorrow); } else { /* * Otherwise, if the day is not today, the format is just the day of the week * (e.g "Wednesday") */ SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE"); return dayFormat.format(dateInMillis); } } }
long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight); long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long localDate = getLocalDateFromUTC(dateInMillis); long dayNumber = getDayNumber(localDate); long currentDayNumber = getDayNumber(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (dayNumber - currentDayNumber < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long startDay = SunshineDateUtils.getNormalizedUtcDateForToday(); date = SunshineDateUtils.getFriendlyDateString(context, dateTimeMillis, false);
/** * Returns just the selection part of the weather query from a normalized today value. * This is used to get a weather forecast from today's date. To make this easy to use * in compound selection, we embed today's date as an argument in the query. * * @return The selection part of the weather query for today onwards */ public static String getSqlSelectForTodayOnwards() { long normalizedUtcNow = SunshineDateUtils.normalizeDate(System.currentTimeMillis()); return WeatherContract.WeatherEntry.COLUMN_DATE + " >= " + normalizedUtcNow; } }
String dateString = SunshineDateUtils.getFriendlyDateString(mContext, dateInMillis, false);
long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(dateInMillis); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis());
/** * Given a day, returns just the name to use for that day. * E.g "today", "tomorrow", "Wednesday". * * @param context Context to use for resource localization * @param dateInMillis The date in milliseconds (local time) * * @return the string day of the week */ private static String getDayName(Context context, long dateInMillis) { /* * If the date is today, return the localized version of "Today" instead of the actual * day name. */ long dayNumber = getDayNumber(dateInMillis); long currentDayNumber = getDayNumber(System.currentTimeMillis()); if (dayNumber == currentDayNumber) { return context.getString(R.string.today); } else if (dayNumber == currentDayNumber + 1) { return context.getString(R.string.tomorrow); } else { /* * Otherwise, if the day is not today, the format is just the day of the week * (e.g "Wednesday") */ SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE"); return dayFormat.format(dateInMillis); } } }
long localDate = getLocalMidnightFromNormalizedUtcDate(normalizedUtcMidnight); long daysFromEpochToProvidedDate = elapsedDaysSinceEpoch(localDate); long daysFromEpochToToday = elapsedDaysSinceEpoch(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (daysFromEpochToProvidedDate - daysFromEpochToToday < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE
long localDate = getLocalDateFromUTC(dateInMillis); long dayNumber = getDayNumber(localDate); long currentDayNumber = getDayNumber(System.currentTimeMillis()); String dayName = getDayName(context, localDate); String readableDate = getReadableDateString(context, localDate); if (dayNumber - currentDayNumber < 2) { return getDayName(context, localDate); } else { int flags = DateUtils.FORMAT_SHOW_DATE