]> git.wh0rd.org Git - tt-rss.git/commitdiff
option HEADLINES_SMART_DATE
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 28 Nov 2005 07:43:03 +0000 (08:43 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 28 Nov 2005 07:43:03 +0000 (08:43 +0100)
backend.php
functions.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql

index 81f566b0154c669abadfc6e1cdce84f4912e7ee8..c81e1ccb1d849a7f1d60e312a531974cafde4668 100644 (file)
                                print "</td>";
                        }
 
-                       $updated_fmt = date(get_pref($link, 'SHORT_DATE_FORMAT'), 
-                               strtotime($line["updated"]));
+                       if (get_pref($link, 'HEADLINES_SMART_DATE')) {
+                               $updated_fmt = smart_date_time(strtotime($line["updated"]));
+                       } else {
+                               $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
+                               $updated_fmt = date($short_date, strtotime($line["updated"]));
+                       }                               
+                       
                        print "<td class=\"hlUpdated\"><nobr>$updated_fmt</nobr></td>";
 
                        print "</tr>";
index f0077efaebbe548ca42be610637facf0b7f67d0d..7a09b9d86bdc5edfdb34cd4ecb81613c32edf659 100644 (file)
                        return null;
                }
        }
+
+       function smart_date_time($timestamp) {
+               if (date("Y.m.d", $timestamp) == date("Y.m.d")) {
+                       return date("G:i", $timestamp);
+               } else if (date("Y.m", $timestamp) == date("Y.m")) {
+                       return date("M d, G:i", $timestamp);
+               } else {
+                       return date("Y/m/d G:i");
+               }
+       }
+
+       function smart_date($timestamp) {
+               if (date("Y.m.d", $timestamp) == date("Y.m.d")) {
+                       return "Today";
+               } else if (date("Y.m", $timestamp) == date("Y.m")) {
+                       return date("D m", $timestamp);
+               } else {
+                       return date("Y/m/d");
+               }
+       }
 ?>
index b7a9686b1bb705880b4747b30282476ff5f0ba29..932e6f3a2e96ab852a45436b11a4fbf3843d37a9 100644 (file)
@@ -200,6 +200,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
 
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SHOW_CONTENT_PREVIEW', 1, 'true', 'Show content preview in headlines list',2);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HEADLINES_SMART_DATE', 1, 'true', 'Use more accessible date/time format for headlines',3);
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index 9204b6573132ac3d178b6061442c4a5668e96760..e4e01f1b0d73e07a891745a6397ce11f30805ca9 100644 (file)
@@ -185,6 +185,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SHORT_DATE_FORMAT', 2, 'M d, G:i', 'Short date format',3);
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('LONG_DATE_FORMAT', 2, 'D, M d Y - G:i', 'Long date format',3);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HEADLINES_SMART_DATE', 1, 'true', 'Use more accessible date/time format for headlines',3);
+
 create table ttrss_user_prefs (
        owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
        pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,