Browse Source

Show year instead of time for old articles

Articles that are older than six months will display the year instead of
the time, e.g. "Aug 11, 2014" instead of "Aug 11, 03:41".
Georg Lukas 10 months ago
parent
commit
0ea83c0487
1 changed files with 6 additions and 1 deletions
  1. 6 1
      org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java

+ 6 - 1
org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleFragment.java

@@ -331,7 +331,12 @@ public class ArticleFragment extends StateSavedFragment  {
             dv.setTextSize(TypedValue.COMPLEX_UNIT_SP, m_articleSmallFontSize);
 
             Date d = new Date(m_article.updated * 1000L);
-            DateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
+            long half_a_year_ago = System.currentTimeMillis()/1000L - 182*24*60*60;
+            DateFormat df;
+            if (m_article.updated < half_a_year_ago)
+                df = new SimpleDateFormat("MMM dd, yyyy");
+            else
+                df = new SimpleDateFormat("MMM dd, HH:mm");
             dv.setText(df.format(d));
         }