Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java

Issue 2701253006: Download Home : Suggested pages header selection (Closed)
Patch Set: talo@ feedback Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
index 95e15539b20546aa8b97e1b408a2ed3439161748..ec129080fac2f2de4a487ba5f79f4c1836fb1528 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
@@ -53,6 +53,8 @@ import org.chromium.ui.widget.Toast;
import java.io.File;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -711,4 +713,25 @@ public class DownloadUtils {
return MIME_TYPE_VIDEO.equals(pieces[0]);
}
+
+ /**
+ * Given two timestamps, calculates if both occur on the same date.
+ * @return True if they belong in the same day. False otherwise.
+ */
+ public static boolean isSameDay(long timestamp1, long timestamp2) {
+ return getDateWithoutTime(timestamp1).equals(getDateWithoutTime(timestamp2));
+ }
+
+ /**
+ * Calculates the {@link Date} for midnight of the date represented by the timestamp.
+ */
+ public static Date getDateWithoutTime(long timestamp) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(timestamp);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ return cal.getTime();
+ }
}

Powered by Google App Engine
This is Rietveld 408576698