get a bunch of stuff right with times and dates, also banish FOF_TIME_OFFSET and replace with a pref

orig_fof
steveminutillo 2007-06-07 02:42:09 +00:00
parent dc57d336ab
commit 8b8aa4cd1a
5 changed files with 25 additions and 19 deletions

View File

@ -13,11 +13,6 @@
*/
// Difference, in hours, between your server and your local time zone.
define('FOF_TIME_OFFSET', 0);
// Database connection information. Host, username, password, database name.
define('FOF_DB_HOST', "host.example.com");

View File

@ -414,23 +414,23 @@ function fof_db_get_items($user_id=1, $feed=NULL, $what="unread", $when=NULL, $s
{
global $FOF_SUBSCRIPTION_TABLE, $FOF_FEED_TABLE, $FOF_ITEM_TABLE, $FOF_ITEM_TAG_TABLE, $FOF_TAG_TABLE;
$prefs = fof_prefs();
$offset = $prefs['tzoffset'];
if(!is_null($when) && $when != "")
{
if($when == "today")
{
$whendate = date( "Y/m/d", time() - (FOF_TIME_OFFSET * 60 * 60) );
$whendate = fof_todays_date();
}
else
{
$whendate = $when;
}
$begin = strtotime($whendate);
$begin = $begin + (FOF_TIME_OFFSET * 60 * 60);
$whendate = explode("/", $whendate);
$begin = gmmktime(0, 0, 0, $whendate[1], $whendate[2], $whendate[0]) - ($offset * 60 * 60);
$end = $begin + (24 * 60 * 60);
$tomorrow = date( "Y/m/d", $begin + (24 * 60 * 60) );
$yesterday = date( "Y/m/d", $begin - (24 * 60 * 60) );
}
if(is_numeric($start))
@ -452,7 +452,7 @@ function fof_db_get_items($user_id=1, $feed=NULL, $what="unread", $when=NULL, $s
if(!is_null($when) && $when != "")
{
$query .= " and $FOF_ITEM_TABLE.item_cached > $begin and $FOF_ITEM_TABLE.item_cached < $end";
$query .= " and $FOF_ITEM_TABLE.item_published > $begin and $FOF_ITEM_TABLE.item_published < $end";
}
if($what != "all")

View File

@ -391,7 +391,7 @@ function fof_get_nav_links($feed=NULL, $what="new", $when=NULL, $start=NULL, $li
{
if($when == "today")
{
$whendate = date( "Y/m/d", time() - (FOF_TIME_OFFSET * 60 * 60) );
$whendate = fof_todays_date();
}
else
{
@ -399,8 +399,6 @@ function fof_get_nav_links($feed=NULL, $what="new", $when=NULL, $start=NULL, $li
}
$begin = strtotime($whendate);
$begin = $begin + (FOF_TIME_OFFSET * 60 * 60);
$end = $begin + (24 * 60 * 60);
$tomorrow = date( "Y/m/d", $begin + (24 * 60 * 60) );
$yesterday = date( "Y/m/d", $begin - (24 * 60 * 60) );
@ -732,4 +730,12 @@ function fof_multi_sort($tab,$key,$rev){
return $tab ;
}
function fof_todays_date()
{
$prefs = fof_prefs();
$offset = $prefs['tzoffset'];
return gmdate( "Y/m/d", time() + ($offset * 60 * 60) );
}
?>

View File

@ -48,9 +48,13 @@ function fof_render_item($item)
$item_title = $item['item_title'];
$item_content = $item['item_content'];
$item_read = $item['item_read'];
$item_published = date("Y-n-d g:ia", $item['item_published']);
$item_cached = date("Y-n-d g:ia", $item['item_cached']);
$item_updated = date("Y-n-d g:ia", $item['item_updated']);
$prefs = fof_prefs();
$offset = $prefs['tzoffset'];
$item_published = gmdate("Y-n-d g:ia", $item['item_published'] + $offset*60*60);
$item_cached = gmdate("Y-n-d g:ia", $item['item_cached'] + $offset*60*60);
$item_updated = gmdate("Y-n-d g:ia", $item['item_updated'] + $offset*60*60);
if(!$item_title) $item_title = "[no title]";

View File

@ -18,6 +18,7 @@ if(isset($_POST['prefs']))
{
$fof_user_prefs['favicons'] = isset($_POST['favicons']);
$fof_user_prefs['keyboard'] = isset($_POST['keyboard']);
$fof_user_prefs['tzoffset'] = intval($_POST['tzoffset']);
fof_db_save_prefs(fof_current_user(), $fof_user_prefs);
@ -59,7 +60,7 @@ $favicons = $_POST['favicons'];
<form method="post" action="prefs.php" style="border: 1px solid black; margin: 10px; padding: 10px;">
Display custom feed favicons? <input type="checkbox" name="favicons" <?php if($fof_user_prefs['favicons']) echo "checked=true";?> ><br><br>
Use keyboard shortcuts? <input type="checkbox" name="keyboard" <?php if($fof_user_prefs['keyboard']) echo "checked=true";?> ><br><br>
Time offset in hours: <input type=string name=offset> (server time: <?php echo date("Y-n-d g:ia") ?>)
Time offset in hours: <input size=3 type=string name=tzoffset value="<?php echo $fof_user_prefs['tzoffset']?>"> (UTC time: <?php echo gmdate("Y-n-d g:ia") ?>, local time: <?php echo gmdate("Y-n-d g:ia", time() + $fof_user_prefs["tzoffset"]*60*60) ?>)
<br><br>
<input type=submit name=prefs value="Save Preferences">
</form>