aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-06-12 22:52:34 -0700
committerfriendica <info@friendica.com>2012-06-12 22:52:34 -0700
commita424fecdae3b54b47778ed7a52452ff80c2bf631 (patch)
tree103207f20fc0ca01ffb942fafe9b3e92ce93db44 /include/items.php
parentf8314d6beafc517cba65bde120edf6beae72a9a8 (diff)
downloadvolse-hubzilla-a424fecdae3b54b47778ed7a52452ff80c2bf631.tar.gz
volse-hubzilla-a424fecdae3b54b47778ed7a52452ff80c2bf631.tar.bz2
volse-hubzilla-a424fecdae3b54b47778ed7a52452ff80c2bf631.zip
this should catch any weirdness caused by being in different timezones and making your first post on the 31st of March
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/include/items.php b/include/items.php
index 2a0a9a426..35a4396dc 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3402,26 +3402,32 @@ function first_post_date($uid,$wall = false) {
);
if(count($r)) {
// logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA);
- return substr($r[0]['created'],0,10);
+ return substr(datetime_convert('',date_default_timezone_get(),$r[0]['created']),0,10);
}
return false;
}
function posted_dates($uid,$wall) {
- $dnow = datetime_convert('','','now','Y-m-d');
+ $dnow = datetime_convert('',date_default_timezone_get(),'now','Y-m-d');
$dthen = first_post_date($uid,$wall);
if(! $dthen)
return array();
+ // If it's near the end of a long month, backup to the 28th so that in
+ // consecutive loops we'll always get a whole month difference.
+
+ if(intval(substr($dnow,8)) > 28)
+ $dnow = substr($dnow,0,8) . '28';
+ if(intval(substr($dthen,8)) > 28)
+ $dnow = substr($dthen,0,8) . '28';
+
$ret = array();
while($dnow >= $dthen) {
$start_month = datetime_convert('','','first day of ' . $dnow,'Y-m-d');
$end_month = datetime_convert('','','last day of ' . $dnow,'Y-m-d');
$str = day_translate(datetime_convert('','',$dnow,'F Y'));
$ret[] = array($str,$end_month,$start_month);
- if($start_month < $dthen)
- break;
$dnow = datetime_convert('','',$dnow . ' -1 month', 'Y-m-d');
}
return $ret;