]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement per-user timezone support; store dates in UTC internally (closes #254)
authorAndrew Dolgov <fox@fakecake.org>
Sun, 7 Nov 2010 15:14:48 +0000 (18:14 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sun, 7 Nov 2010 15:14:48 +0000 (18:14 +0300)
14 files changed:
functions.php
lib/timezones.txt [new file with mode: 0644]
mobile/classic/functions.php
mobile/functions.php
modules/pref-feeds.php
modules/pref-prefs.php
modules/pref-users.php
prefs.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/68.sql [new file with mode: 0644]
schema/versions/pgsql/68.sql [new file with mode: 0644]
tt-rss.php

index d787b71862996cc470edf97c62d5f6c1c6ca10a5..8ef14d70b73d1fa32042b0c58c3af95db6ad813d 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+       date_default_timezone_set('UTC');
+
        if ($_REQUEST["debug"]) {
                define('DEFAULT_ERROR_LEVEL', E_ALL);
        }
                return $rv;
        }
 
+       function make_local_datetime($link, $timestamp, $long, $owner_uid = false,
+                                       $no_smart_dt = false) {
+
+               if (!$owner_uid) $owner_uid = $_SESSION['uid'];
+               if (!$timestamp) $timestamp = '1970-01-01 0:00';
+
+               $user_tz_string = get_pref($link, 'USER_TIMEZONE', $owner_uid);
+
+               try {
+                       $user_tz = new DateTimeZone($user_tz_string);
+               } catch (Exception $e) {
+                       $user_tz = new DateTimeZone('UTC');
+               }
+
+               # We store date in UTC internally
+               $dt = new DateTime($timestamp, new DateTimeZone('UTC'));
+               $user_timestamp = $dt->format('U') + $user_tz->getOffset($dt);
+
+               if (!$no_smart_dt && get_pref($link, 'HEADLINES_SMART_DATE', $owner_uid)) {
+                       return smart_date_time($user_timestamp);
+               } else {
+                       if ($long)
+                               $format = get_pref($link, 'LONG_DATE_FORMAT', $owner_uid);
+                       else
+                               $format = get_pref($link, 'SHORT_DATE_FORMAT', $owner_uid);
+
+                       return date($format, $user_timestamp);
+               }
+       }
+
        function smart_date_time($timestamp) {
                if (date("Y.m.d", $timestamp) == date("Y.m.d")) {
                        return date("G:i", $timestamp);
                $result = db_query($link, $query);
                $fctrs_modified = false;
 
-               $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
-
                while ($line = db_fetch_assoc($result)) {
                
                        $id = $line["id"];
                        $count = $line["count"];
                        $last_error = htmlspecialchars($line["last_error"]);
 
-                       if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                               $last_updated = smart_date_time(strtotime($line["last_updated"]));
-                       } else {
-                               $last_updated = date($short_date, strtotime($line["last_updated"]));
-                       }                               
+                       $last_updated = make_local_datetime($link, $line['last_updated'], false);
 
                        $has_img = feed_has_icon($id);
 
 
                        array_push($affected_ids, $line["ref_id"]);
 
-                       $updated = smart_date_time(strtotime($line["last_updated"]));
+                       $updated = make_local_datetime($link, $line['last_updated'], false,
+                               $user_id);
 
                        $tpl->setVariable('FEED_TITLE', $line["feed_title"]);
                        $tpl->setVariable('ARTICLE_TITLE', $line["title"]);
                        $total_unread = 0;
 
                        $category = "";
-
-                       $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
        
                        while ($line = db_fetch_assoc($result)) {
                        
        
                                $subop = $_REQUEST["subop"];
 
-                               if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                                       $last_updated = smart_date_time(strtotime($line["last_updated_noms"]));
-                               } else {
-                                       $last_updated = date($short_date, strtotime($line["last_updated_noms"]));
-                               }
+                               $last_updated = make_local_datetime($link, $line['last_updated_noms'], 
+                                       false);
 
                                $rtl_content = sql_bool_to_bool($line["rtl_content"]);
 
                                $entry_author = __(" - ") . $entry_author;
                        }
 
-                       $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT')
-                               strtotime($line["updated"]));
-               
+                       $parsed_updated = make_local_datetime($link, $line["updated"], true
+                               false, true);
+
                        print "<div class=\"postDate$rtl_class\">$parsed_updated</div>";
 
                        if ($line["link"]) {
 #                              $content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
 #                                      $line["title"] . "</a>";
 
-                               if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                                       $updated_fmt = smart_date_time(strtotime($line["updated_noms"]));
-                               } else {
-                                       $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
-                                       $updated_fmt = date($short_date, strtotime($line["updated_noms"]));
-                               }                               
+                               $updated_fmt = make_local_datetime($link, $line["updated_noms"], false);        
 
                                if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) {
                                        $content_preview = truncate_string(strip_tags($line["content_preview"]), 
                        pg_query($link, "set client_encoding = 'UTF-8'");
                        pg_set_client_encoding("UNICODE");
                        pg_query($link, "set datestyle = 'ISO, european'");
+                       pg_query($link, "set TIME ZONE 0");
                } else {
+                       db_query($link, "SET time_zone = '+0:0'");
+
                        if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
                                db_query($link, "SET NAMES " . MYSQL_CHARSET);
        //                      db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
                        WHERE owner_uid = " . $_SESSION['uid']);
 
                $last_updated = db_fetch_result($result, 0, "last_updated");
-
-               if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                       $last_updated = smart_date_time(strtotime($last_updated));
-               } else {
-                       $last_updated = date($short_date, strtotime($last_updated));
-               }                               
+               $last_updated = make_local_datetime($link, $last_updated, false);
 
                printf(__("Feeds last updated at %s"), $last_updated);
 
diff --git a/lib/timezones.txt b/lib/timezones.txt
new file mode 100644 (file)
index 0000000..66824ec
--- /dev/null
@@ -0,0 +1,567 @@
+Africa/Abidjan
+Africa/Accra
+Africa/Addis_Ababa
+Africa/Algiers
+Africa/Asmara
+Africa/Asmera
+Africa/Bamako
+Africa/Bangui
+Africa/Banjul
+Africa/Bissau
+Africa/Blantyre
+Africa/Brazzaville
+Africa/Bujumbura
+Africa/Cairo
+Africa/Casablanca
+Africa/Ceuta
+Africa/Conakry
+Africa/Dakar
+Africa/Dar_es_Salaam
+Africa/Djibouti
+Africa/Douala
+Africa/El_Aaiun
+Africa/Freetown
+Africa/Gaborone
+Africa/Harare
+Africa/Johannesburg
+Africa/Kampala
+Africa/Khartoum
+Africa/Kigali
+Africa/Kinshasa
+Africa/Lagos
+Africa/Libreville
+Africa/Lome
+Africa/Luanda
+Africa/Lubumbashi
+Africa/Lusaka
+Africa/Malabo
+Africa/Maputo
+Africa/Maseru
+Africa/Mbabane
+Africa/Mogadishu
+Africa/Monrovia
+Africa/Nairobi
+Africa/Ndjamena
+Africa/Niamey
+Africa/Nouakchott
+Africa/Ouagadougou
+Africa/Porto-Novo
+Africa/Sao_Tome
+Africa/Timbuktu
+Africa/Tripoli
+Africa/Tunis
+Africa/Windhoek
+America/Adak
+America/Anchorage
+America/Anguilla
+America/Antigua
+America/Araguaina
+America/Argentina/Buenos_Aires
+America/Argentina/Catamarca
+America/Argentina/ComodRivadavia
+America/Argentina/Cordoba
+America/Argentina/Jujuy
+America/Argentina/La_Rioja
+America/Argentina/Mendoza
+America/Argentina/Rio_Gallegos
+America/Argentina/Salta
+America/Argentina/San_Juan
+America/Argentina/San_Luis
+America/Argentina/Tucuman
+America/Argentina/Ushuaia
+America/Aruba
+America/Asuncion
+America/Atikokan
+America/Atka
+America/Bahia
+America/Bahia_Banderas
+America/Barbados
+America/Belem
+America/Belize
+America/Blanc-Sablon
+America/Boa_Vista
+America/Bogota
+America/Boise
+America/Buenos_Aires
+America/Cambridge_Bay
+America/Campo_Grande
+America/Cancun
+America/Caracas
+America/Catamarca
+America/Cayenne
+America/Cayman
+America/Chicago
+America/Chihuahua
+America/Coral_Harbour
+America/Cordoba
+America/Costa_Rica
+America/Cuiaba
+America/Curacao
+America/Danmarkshavn
+America/Dawson
+America/Dawson_Creek
+America/Denver
+America/Detroit
+America/Dominica
+America/Edmonton
+America/Eirunepe
+America/El_Salvador
+America/Ensenada
+America/Fort_Wayne
+America/Fortaleza
+America/Glace_Bay
+America/Godthab
+America/Goose_Bay
+America/Grand_Turk
+America/Grenada
+America/Guadeloupe
+America/Guatemala
+America/Guayaquil
+America/Guyana
+America/Halifax
+America/Havana
+America/Hermosillo
+America/Indiana/Indianapolis
+America/Indiana/Knox
+America/Indiana/Marengo
+America/Indiana/Petersburg
+America/Indiana/Tell_City
+America/Indiana/Vevay
+America/Indiana/Vincennes
+America/Indiana/Winamac
+America/Indianapolis
+America/Inuvik
+America/Iqaluit
+America/Jamaica
+America/Jujuy
+America/Juneau
+America/Kentucky/Louisville
+America/Kentucky/Monticello
+America/Knox_IN
+America/La_Paz
+America/Lima
+America/Los_Angeles
+America/Louisville
+America/Maceio
+America/Managua
+America/Manaus
+America/Marigot
+America/Martinique
+America/Matamoros
+America/Mazatlan
+America/Mendoza
+America/Menominee
+America/Merida
+America/Mexico_City
+America/Miquelon
+America/Moncton
+America/Monterrey
+America/Montevideo
+America/Montreal
+America/Montserrat
+America/Nassau
+America/New_York
+America/Nipigon
+America/Nome
+America/Noronha
+America/North_Dakota/Center
+America/North_Dakota/New_Salem
+America/Ojinaga
+America/Panama
+America/Pangnirtung
+America/Paramaribo
+America/Phoenix
+America/Port-au-Prince
+America/Port_of_Spain
+America/Porto_Acre
+America/Porto_Velho
+America/Puerto_Rico
+America/Rainy_River
+America/Rankin_Inlet
+America/Recife
+America/Regina
+America/Resolute
+America/Rio_Branco
+America/Rosario
+America/Santa_Isabel
+America/Santarem
+America/Santiago
+America/Santo_Domingo
+America/Sao_Paulo
+America/Scoresbysund
+America/Shiprock
+America/St_Barthelemy
+America/St_Johns
+America/St_Kitts
+America/St_Lucia
+America/St_Thomas
+America/St_Vincent
+America/Swift_Current
+America/Tegucigalpa
+America/Thule
+America/Thunder_Bay
+America/Tijuana
+America/Toronto
+America/Tortola
+America/Vancouver
+America/Virgin
+America/Whitehorse
+America/Winnipeg
+America/Yakutat
+America/Yellowknife
+Antarctica/Casey
+Antarctica/Davis
+Antarctica/DumontDUrville
+Antarctica/Macquarie
+Antarctica/Mawson
+Antarctica/McMurdo
+Antarctica/Palmer
+Antarctica/Rothera
+Antarctica/South_Pole
+Antarctica/Syowa
+Antarctica/Vostok
+Arctic/Longyearbyen
+Asia/Aden
+Asia/Almaty
+Asia/Amman
+Asia/Anadyr
+Asia/Aqtau
+Asia/Aqtobe
+Asia/Ashgabat
+Asia/Ashkhabad
+Asia/Baghdad
+Asia/Bahrain
+Asia/Baku
+Asia/Bangkok
+Asia/Beirut
+Asia/Bishkek
+Asia/Brunei
+Asia/Calcutta
+Asia/Choibalsan
+Asia/Chongqing
+Asia/Chungking
+Asia/Colombo
+Asia/Dacca
+Asia/Damascus
+Asia/Dhaka
+Asia/Dili
+Asia/Dubai
+Asia/Dushanbe
+Asia/Gaza
+Asia/Harbin
+Asia/Ho_Chi_Minh
+Asia/Hong_Kong
+Asia/Hovd
+Asia/Irkutsk
+Asia/Istanbul
+Asia/Jakarta
+Asia/Jayapura
+Asia/Jerusalem
+Asia/Kabul
+Asia/Kamchatka
+Asia/Karachi
+Asia/Kashgar
+Asia/Kathmandu
+Asia/Katmandu
+Asia/Kolkata
+Asia/Krasnoyarsk
+Asia/Kuala_Lumpur
+Asia/Kuching
+Asia/Kuwait
+Asia/Macao
+Asia/Macau
+Asia/Magadan
+Asia/Makassar
+Asia/Manila
+Asia/Muscat
+Asia/Nicosia
+Asia/Novokuznetsk
+Asia/Novosibirsk
+Asia/Omsk
+Asia/Oral
+Asia/Phnom_Penh
+Asia/Pontianak
+Asia/Pyongyang
+Asia/Qatar
+Asia/Qyzylorda
+Asia/Rangoon
+Asia/Riyadh
+Asia/Saigon
+Asia/Sakhalin
+Asia/Samarkand
+Asia/Seoul
+Asia/Shanghai
+Asia/Singapore
+Asia/Taipei
+Asia/Tashkent
+Asia/Tbilisi
+Asia/Tehran
+Asia/Tel_Aviv
+Asia/Thimbu
+Asia/Thimphu
+Asia/Tokyo
+Asia/Ujung_Pandang
+Asia/Ulaanbaatar
+Asia/Ulan_Bator
+Asia/Urumqi
+Asia/Vientiane
+Asia/Vladivostok
+Asia/Yakutsk
+Asia/Yekaterinburg
+Asia/Yerevan
+Atlantic/Azores
+Atlantic/Bermuda
+Atlantic/Canary
+Atlantic/Cape_Verde
+Atlantic/Faeroe
+Atlantic/Faroe
+Atlantic/Jan_Mayen
+Atlantic/Madeira
+Atlantic/Reykjavik
+Atlantic/South_Georgia
+Atlantic/St_Helena
+Atlantic/Stanley
+Australia/ACT
+Australia/Adelaide
+Australia/Brisbane
+Australia/Broken_Hill
+Australia/Canberra
+Australia/Currie
+Australia/Darwin
+Australia/Eucla
+Australia/Hobart
+Australia/LHI
+Australia/Lindeman
+Australia/Lord_Howe
+Australia/Melbourne
+Australia/North
+Australia/NSW
+Australia/Perth
+Australia/Queensland
+Australia/South
+Australia/Sydney
+Australia/Tasmania
+Australia/Victoria
+Australia/West
+Australia/Yancowinna
+Brazil/Acre
+Brazil/DeNoronha
+Brazil/East
+Brazil/West
+Canada/Atlantic
+Canada/Central
+Canada/East-Saskatchewan
+Canada/Eastern
+Canada/Mountain
+Canada/Newfoundland
+Canada/Pacific
+Canada/Saskatchewan
+Canada/Yukon
+CET
+Chile/Continental
+Chile/EasterIsland
+CST6CDT
+Cuba
+EET
+Egypt
+Eire
+EST
+EST5EDT
+Etc/GMT
+Etc/GMT+0
+Etc/GMT+1
+Etc/GMT+10
+Etc/GMT+11
+Etc/GMT+12
+Etc/GMT+2
+Etc/GMT+3
+Etc/GMT+4
+Etc/GMT+5
+Etc/GMT+6
+Etc/GMT+7
+Etc/GMT+8
+Etc/GMT+9
+Etc/GMT-0
+Etc/GMT-1
+Etc/GMT-10
+Etc/GMT-11
+Etc/GMT-12
+Etc/GMT-13
+Etc/GMT-14
+Etc/GMT-2
+Etc/GMT-3
+Etc/GMT-4
+Etc/GMT-5
+Etc/GMT-6
+Etc/GMT-7
+Etc/GMT-8
+Etc/GMT-9
+Etc/GMT0
+Etc/Greenwich
+Etc/UCT
+Etc/Universal
+Etc/UTC
+Etc/Zulu
+Europe/Amsterdam
+Europe/Andorra
+Europe/Athens
+Europe/Belfast
+Europe/Belgrade
+Europe/Berlin
+Europe/Bratislava
+Europe/Brussels
+Europe/Bucharest
+Europe/Budapest
+Europe/Chisinau
+Europe/Copenhagen
+Europe/Dublin
+Europe/Gibraltar
+Europe/Guernsey
+Europe/Helsinki
+Europe/Isle_of_Man
+Europe/Istanbul
+Europe/Jersey
+Europe/Kaliningrad
+Europe/Kiev
+Europe/Lisbon
+Europe/Ljubljana
+Europe/London
+Europe/Luxembourg
+Europe/Madrid
+Europe/Malta
+Europe/Mariehamn
+Europe/Minsk
+Europe/Monaco
+Europe/Moscow
+Europe/Nicosia
+Europe/Oslo
+Europe/Paris
+Europe/Podgorica
+Europe/Prague
+Europe/Riga
+Europe/Rome
+Europe/Samara
+Europe/San_Marino
+Europe/Sarajevo
+Europe/Simferopol
+Europe/Skopje
+Europe/Sofia
+Europe/Stockholm
+Europe/Tallinn
+Europe/Tirane
+Europe/Tiraspol
+Europe/Uzhgorod
+Europe/Vaduz
+Europe/Vatican
+Europe/Vienna
+Europe/Vilnius
+Europe/Volgograd
+Europe/Warsaw
+Europe/Zagreb
+Europe/Zaporozhye
+Europe/Zurich
+Factory
+GB
+GB-Eire
+GMT
+GMT+0
+GMT-0
+GMT0
+Greenwich
+Hongkong
+HST
+Iceland
+Indian/Antananarivo
+Indian/Chagos
+Indian/Christmas
+Indian/Cocos
+Indian/Comoro
+Indian/Kerguelen
+Indian/Mahe
+Indian/Maldives
+Indian/Mauritius
+Indian/Mayotte
+Indian/Reunion
+Iran
+Israel
+Jamaica
+Japan
+Kwajalein
+Libya
+MET
+Mexico/BajaNorte
+Mexico/BajaSur
+Mexico/General
+MST
+MST7MDT
+Navajo
+NZ
+NZ-CHAT
+Pacific/Apia
+Pacific/Auckland
+Pacific/Chatham
+Pacific/Chuuk
+Pacific/Easter
+Pacific/Efate
+Pacific/Enderbury
+Pacific/Fakaofo
+Pacific/Fiji
+Pacific/Funafuti
+Pacific/Galapagos
+Pacific/Gambier
+Pacific/Guadalcanal
+Pacific/Guam
+Pacific/Honolulu
+Pacific/Johnston
+Pacific/Kiritimati
+Pacific/Kosrae
+Pacific/Kwajalein
+Pacific/Majuro
+Pacific/Marquesas
+Pacific/Midway
+Pacific/Nauru
+Pacific/Niue
+Pacific/Norfolk
+Pacific/Noumea
+Pacific/Pago_Pago
+Pacific/Palau
+Pacific/Pitcairn
+Pacific/Pohnpei
+Pacific/Ponape
+Pacific/Port_Moresby
+Pacific/Rarotonga
+Pacific/Saipan
+Pacific/Samoa
+Pacific/Tahiti
+Pacific/Tarawa
+Pacific/Tongatapu
+Pacific/Truk
+Pacific/Wake
+Pacific/Wallis
+Pacific/Yap
+Poland
+Portugal
+PRC
+PST8PDT
+ROC
+ROK
+Singapore
+Turkey
+UCT
+Universal
+US/Alaska
+US/Aleutian
+US/Arizona
+US/Central
+US/East-Indiana
+US/Eastern
+US/Hawaii
+US/Indiana-Starke
+US/Michigan
+US/Mountain
+US/Pacific
+US/Pacific-New
+US/Samoa
+UTC
+W-SU
+WET
index bd61bbfd257a0c2a22bd24bc6ef9200b5c35359c..4cb58308e763060dc42c91574ef0f28cad224207 100644 (file)
                                $content_link = "<a href=\"?go=view&id=$id&cat=$cat_view&ret_feed=$feed&feed=$feed_id\">" .
                                        $line["title"] . "</a>";
 
-                               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"]));
-                               }                               
-                               
+                               $updated_fmt = make_local_datetime($link, $line['updated'], false);
+
                                print "<li class='$class' id=\"HROW-$id\">";
 
                                print "<input type=\"checkbox\" name=\"sel_ids[$id]\"
index 18440bab942c9dec85fe15c3c0e77dc2deb076a4..6dec6440d4fe86a7a7367f53900ba48007c9bf03 100644 (file)
                                WHERE ref_id = '$id'
                                AND owner_uid = " . $_SESSION["uid"]);
 
-                       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"]));
-                       }                               
-       
+                       $updated_fmt = make_local_datetime($link, $line['updated'], false);
+
                        $title = $line["title"];
                        $article_link = $line["link"];
        
index b106797761920292d59f8cedbfe28ad364b7b213..376980ce3f6894371515f6c449a4e850b52da106 100644 (file)
 
                                if (!$last_updated) {
                                        $last_updated = "&mdash;";
-                               } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                                       $last_updated = smart_date_time(strtotime($last_updated));
                                } else {
-                                       $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
-                                       $last_updated = date($short_date, strtotime($last_updated));
+                                       $last_updated = make_local_datetime($link, $last_updated, false);
                                }
 
                                $last_article = $line["last_article"];
 
                                if (!$last_article) {
                                        $last_article = "&mdash;";      
-                               } else if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                                       $last_article = smart_date_time(strtotime($last_article));
                                } else {
-                                       $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
-                                       $last_article = date($short_date, strtotime($last_article));
+                                       $last_article = make_local_datetime($link, $last_article, false);
                                }
 
                                if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
index 5105f3573d4162e18d6557ab7b817f2d63288d0d..f5671a99562ecdbd8232408fc3fe124b8ae0a2ed 100644 (file)
 
                                print "<td class=\"prefValue\">";
 
-                               if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
+                               if ($pref_name == "USER_TIMEZONE") {
+
+                                       $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
+
+                                       print_select($pref_name, $value, $timezones);
+
+                               } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
 
                                        global $update_intervals_nodefault;
 
index 57be9b89520b89fc937b740becb42a3de6c90d37..7321f19d4cb0dfae45b644c90b913cc391b6edf3 100644 (file)
 
                        print "<table width='100%'>";
 
-                       $last_login = date(get_pref($link, 'LONG_DATE_FORMAT'),
-                               strtotime(db_fetch_result($result, 0, "last_login")));
+                       $last_login = make_local_datetime($link,
+                               db_fetch_result($result, 0, "last_login"));
 
-                       $created = date(get_pref($link, 'LONG_DATE_FORMAT'),
-                               strtotime(db_fetch_result($result, 0, "created")));
+                       $created = make_local_datetime($link,
+                               db_fetch_result($result, 0, "created"));
 
                        $access_level = db_fetch_result($result, 0, "access_level");
                        $stored_articles = db_fetch_result($result, 0, "stored_articles");
 
                        $line["login"] = htmlspecialchars($line["login"]);
 
-#                      $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'),
-#                              strtotime($line["last_login"]));
-
-                       if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                               $line["last_login"] = smart_date_time(strtotime($line["last_login"]));
-                               $line["created"] = smart_date_time(strtotime($line["created"]));
-                       } else {
-                               $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'),
-                                       strtotime($line["last_login"]));
-                               $line["created"] = date(get_pref($link, 'SHORT_DATE_FORMAT'),
-                                       strtotime($line["created"]));
-                       }                               
+                       $line["created"] = make_local_datetime($link, $line["created"], false);
+                       $line["last_login"] = make_local_datetime($link, $line["last_login"], false);
 
                        print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"user\");' 
                                type=\"checkbox\" id=\"UMCHK-$uid\"></td>";
index 41608969880f5170b11c190a7b34075010cd7df3..756a23fe13009dfcd1ffb36abf4781a343617b9c 100644 (file)
--- a/prefs.php
+++ b/prefs.php
@@ -10,6 +10,8 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
 
+       init_connection($link);
+
        login_sequence($link);
 
        $dt_add = get_script_dt_add();
index 21b6598659f85b5d7cba7c63ce2b669a22028ce8..7b9c1199c189606f2578d41df9d33ec5f6366edc 100644 (file)
@@ -2,7 +2,7 @@
        require_once "functions.php";
 
        define('EXPECTED_CONFIG_VERSION', 19);
-       define('SCHEMA_VERSION', 67);
+       define('SCHEMA_VERSION', 68);
 
        if (!file_exists("config.php")) {
                print "<b>Fatal Error</b>: You forgot to copy 
index fbac36007278c4a2e090e78ab4a9649211c1a3aa..b6ac57fc438ed41201338899530d5b91f9543e1e 100644 (file)
@@ -241,7 +241,7 @@ create table ttrss_tags (id integer primary key auto_increment,
 
 create table ttrss_version (schema_version int not null) TYPE=InnoDB;
 
-insert into ttrss_version values (67);
+insert into ttrss_version values (68);
 
 create table ttrss_enclosures (id integer primary key auto_increment,
        content_url text not null,
@@ -400,6 +400,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('_THEME_ID', 2, '0', '', 1);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
+
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
index f4589c769899b8eb3ebc5499386c725dc98be900..64d00dda79691ef08e970408b17f22c611d0dd27 100644 (file)
@@ -213,7 +213,7 @@ create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
 
 create table ttrss_version (schema_version int not null);
 
-insert into ttrss_version values (67);
+insert into ttrss_version values (68);
 
 create table ttrss_enclosures (id serial not null primary key,
        content_url text not null,
@@ -364,6 +364,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('_THEME_ID', 2, '0', '', 1);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
+
 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,
diff --git a/schema/versions/mysql/68.sql b/schema/versions/mysql/68.sql
new file mode 100644 (file)
index 0000000..6d56df0
--- /dev/null
@@ -0,0 +1,7 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
+
+update ttrss_version set schema_version = 68;
+
+commit;
diff --git a/schema/versions/pgsql/68.sql b/schema/versions/pgsql/68.sql
new file mode 100644 (file)
index 0000000..6d56df0
--- /dev/null
@@ -0,0 +1,7 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
+
+update ttrss_version set schema_version = 68;
+
+commit;
index f41d422396d0a853e3d192132d14dbe7d3fa0694..2dbf78b7d26564f51cf8552fae70304fe9f0ac66 100644 (file)
@@ -10,6 +10,8 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
 
+       init_connection($link);
+
        login_sequence($link);
 
        $dt_add = get_script_dt_add();