function first_post(&$a, $channel_hash) { if ($channel_hash == '') { json_error_die(422, 'Unprocessable Entity', 'Must supply channel_hash parameter.'); } $first = first_post_date(get_channel_id($channel_hash)); if (!$first) { json_error_die(404, 'Not Found', "No posts for " . $channel_hash); } json_return_and_die(array("status" => "OK", "date" => $first)); }
function posted_dates($uid, $wall) { $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) { $dthen = substr($dthen, 0, 8) . '28'; } $ret = array(); // Starting with the current month, get the first and last days of every // month down to and including the month of the first post while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) { $dstart = substr($dnow, 0, 8) . '01'; $dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5))); $start_month = datetime_convert('', '', $dstart, 'Y-m-d'); $end_month = datetime_convert('', '', $dend, 'Y-m-d'); $str = day_translate(datetime_convert('', '', $dnow, 'F Y')); $ret[] = array($str, $end_month, $start_month); $dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d'); } return $ret; }
function posted_dates($uid, $wall) { $dnow = datetime_convert('', date_default_timezone_get(), 'now', 'Y-m-d'); $dthen = first_post_date($uid, $wall); if (!$dthen) { return array(); } // Set the start and end date to the beginning of the month $dnow = substr($dnow, 0, 8) . '01'; $dthen = substr($dthen, 0, 8) . '01'; $ret = array(); // Starting with the current month, get the first and last days of every // month down to and including the month of the first post while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) { $dstart = substr($dnow, 0, 8) . '01'; $dend = substr($dnow, 0, 8) . get_dim(intval($dnow), intval(substr($dnow, 5))); $start_month = datetime_convert('', '', $dstart, 'Y-m-d'); $end_month = datetime_convert('', '', $dend, 'Y-m-d'); $str = day_translate(datetime_convert('', '', $dnow, 'F Y')); $ret[] = array($str, $end_month, $start_month); $dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d'); } return $ret; }