当前位置: 首页>>代码示例>>PHP>>正文


PHP PSU::date_diff方法代码示例

本文整理汇总了PHP中PSU::date_diff方法的典型用法代码示例。如果您正苦于以下问题:PHP PSU::date_diff方法的具体用法?PHP PSU::date_diff怎么用?PHP PSU::date_diff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PSU的用法示例。


在下文中一共展示了PSU::date_diff方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse_data

 /**
  * Method to parse the source's data into a standard format
  */
 protected function parse_data()
 {
     // Create a normalized feed array (to be served later)
     $parsed_data = array();
     // Let's loop through each "tweet"
     foreach ($this->data as $tweet) {
         // Set reusable timestamp variable
         $timestamp = strtotime($tweet['created_at']);
         $parsed_data[] = array('source' => 'Twitter', 'title' => $tweet['user']['name'], 'userid' => $tweet['user']['id'], 'rawtime' => $tweet['created_at'], 'timestamp' => $timestamp, 'datetime' => \PSU::html5_datetime($timestamp), 'time_ago' => \PSU::date_diff($timestamp, time(), 'simple'), 'url' => 'https://twitter.com/' . $tweet['user']['screen_name'] . '/status/' . $tweet['id_str'], 'text' => $tweet['text']);
     }
     return $parsed_data;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:15,代码来源:Twitter.php

示例2: parse_data

 /**
  * Method to parse the source's data into a standard format
  */
 protected function parse_data()
 {
     // Create a normalized feed array (to be served later)
     $parsed_data = array();
     // Reference just the feed
     $feed = $this->data->feed;
     // If the feed doesn't have a title, give it a generic name
     $feed_title = $feed->title();
     if (strlen($feed_title) <= 0) {
         $feed_title = 'Plymouth State News';
     }
     // Let's loop through each article
     $item_count = 0;
     foreach ($feed as $item) {
         // If we've gone over the post limit setting, then break out of this loop
         if ($item_count > $this->post_limit) {
             // Stop adding posts from this feed
             break;
         }
         // Cut posts if they're too old
         $post_timestamp = strtotime($item->pubDate());
         if (time() - $post_timestamp > $this->old_post_days * 86400) {
             // Skip adding this one... its too old
             continue;
         }
         // Quick function to clean the posts text
         $clean_the_post = function ($post) {
             // Run some cleaners on the string
             $post = htmlspecialchars_decode($post);
             $post = html_entity_decode($post);
             $post = strip_tags($post);
             $post = \PSU::html_all_entities($post);
             $post = str_replace('&#12287;', '\'', $post);
             return $post;
         };
         $post_text = $clean_the_post($item->title());
         // Add the posts data to the normalized array
         $parsed_data[] = array('source' => 'RSS', 'title' => $feed_title, 'userid' => '', 'rawtime' => $item->pubDate(), 'timestamp' => $post_timestamp, 'datetime' => \PSU::html5_datetime($post_timestamp), 'time_ago' => \PSU::date_diff($post_timestamp, time(), 'simple'), 'url' => $item->link(), 'text' => $post_text, 'description' => $item->description(), 'content' => $item->content());
         $item_count++;
     }
     return $parsed_data;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:45,代码来源:Rss.php

示例3: parse_data

 /**
  * Method to parse the source's data into a standard format
  */
 protected function parse_data()
 {
     // Create a normalized feed array (to be served later)
     $parsed_data = array();
     // Let's loop through each post
     foreach ($this->data['data'] as $post) {
         // Set reusable timestamp variable
         $timestamp = strtotime($post['created_time']);
         // If the message data is empty, but the name/title isn't, just set the message to have the value of the name
         if (empty($post['message']) && !empty($post['name'])) {
             $post['message'] = $post['name'];
         }
         // If the post's message is empty $this->remove_empty_message_posts is set to true
         if (empty($post['message']) && $this->remove_empty_message_posts) {
             // Just skip adding the post
             continue;
         }
         $parsed_data[] = array('source' => 'Facebook', 'title' => $post['from']['name'], 'userid' => $post['from']['id'], 'rawtime' => $post['created_time'], 'timestamp' => $timestamp, 'datetime' => \PSU::html5_datetime($timestamp), 'time_ago' => \PSU::date_diff($timestamp, time(), 'simple'), 'url' => $post['actions'][0]['link'], 'text' => $post['message']);
     }
     return $parsed_data;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:24,代码来源:Facebook.php

示例4: getOpenCalls

function getOpenCalls($options = array())
{
    /* Options include the following:
    		which: 
    			all - all open calls
    			mygroup - all open calls in groups that option['calllog_username'] is in
    			unassigned - calls that are currently not assigned to a user or group
    			caller - open calls for $option['caller_user_name']
    			today - calls opened today
    			my_opened - calls that I opened
    			my - calls assigned to me, or opted into seeing via high priority groups setting
    		who: 
    			should contain the the username of the person you are searching on (could be caller or calllog_user)
    		what: 
    			a comma separated list of fields to fetch, defaults to * if not provided
    		sort_by:
    			call_date - when the call was created
    			call_updated - when the call was last updated
    	*/
    $options['what'] = $options['what'] ?: '*';
    $query = "SELECT {$options['what']} \n\t\t\t\tFROM call_log, \n\t\t\t\t\t call_history \n\t\t\t\tWHERE call_log.call_id = call_history.call_id \n\t\t\t\t\tAND call_history.call_status='open'";
    switch ($options['which']) {
        case '':
        case 'none':
        case 'all':
            $query = "SELECT {$options['what']} \n\t\t\t\t\t\tFROM call_log \n\t\t\t\t\t\t\tLEFT JOIN call_history ON call_log.call_id = call_history.call_id \n\t\t\t\t\t\t\tLEFT JOIN itsgroups ON its_assigned_group = itsgroups.itsgroupid \n\t\t\t\t\t\tWHERE call_history.call_status = 'open' \n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\thide_in_all_calls != '1' \n\t\t\t\t\t\t\t\tOR hide_in_all_calls IS NULL\n\t\t\t\t\t\t\t\t)";
            break;
        case 'mygroup':
            $query = "SELECT {$options['what']} \n\t\t\t\t\t\tFROM call_log, call_history \n\t\t\t\t\t\tWHERE call_log.call_id = call_history.call_id \n\t\t\t\t\t\t\tAND call_history.its_assigned_group='{$options['who']}' \n\t\t\t\t\t\t\tAND call_history.call_status='open'";
            break;
        case 'unassigned':
            $query .= " AND tlc_assigned_to='unassigned' AND (its_assigned_group='0' || its_assigned_group='unassigned' || its_assigned_group='')";
            break;
        case 'caller':
            $person = new PSUPerson($options['who']);
            $query .= " AND (call_log.wp_id = '{$person->wp_id}' OR call_log.pidm = {$person->pidm} OR call_log.caller_username='{$options['who']}')";
            break;
        case 'today':
            $query .= " AND call_log.call_date=NOW()";
            break;
        case 'my_opened':
            $query .= " AND call_log.calllog_username='{$options['who']}' AND call_history.call_status='open'";
            break;
        case 'my':
            $query .= " AND ( call_history.tlc_assigned_to='{$options['who']}'";
            $high_priority_groups = implode(',', User::getHighPriorityGroups(false, $options['who']));
            if ($high_priority_groups) {
                $query .= " OR ( call_history.its_assigned_group IN ({$high_priority_groups}) AND call_history.call_priority = 'high' )";
            }
            $query .= " )";
            break;
        default:
            $query .= " AND call_history.tlc_assigned_to='{$options['who']}'";
            break;
    }
    // end switch
    $query .= " AND call_history.current='1'";
    if (!$options['sort_by'] || $options['sort_by'] == 'call_date') {
        $options['sort_by'] = 'call_date, call_time';
    } elseif ($options['sort_by'] == 'call_updated') {
        $options['sort_by'] = 'date_assigned, time_assigned';
    }
    $query .= " ORDER BY {$options['sort_by']} ASC";
    $calls = PSU::db('calllog')->GetAll($query);
    foreach ($calls as &$call) {
        // needed for the template, but a bit redundant
        $call['call_title'] = $call['title'];
        // determine an assigned_to that combines person and queue/group
        $groupArray = getGroupInfo($call['its_assigned_group']);
        if ($call['its_assigned_group'] != 0 || $groupArray[1] != '') {
            if ($call['tlc_assigned_to'] != 'unassigned') {
                $call['assigned_to']['group'] = $groupArray[1];
                $call['assigned_to'][] = $call['tlc_assigned_to'];
            } else {
                $call['assigned_to']['group'] = $groupArray[1];
            }
        } elseif ($call['tlc_assigned_to'] != '') {
            $call['assigned_to'][] = $call['tlc_assigned_to'];
        } else {
            $call['assigned_to'][] = 'None';
        }
        $call['building_name'] = getBuildingName($call['location_building_id']);
        if ($call['date_assigned']) {
            $assign_datetime = $call['date_assigned'] . ' ' . $call['time_assigned'];
            $call['activity_datetime'] = time() - strtotime($assign_datetime);
            $call['date_assigned'] = date('M j, Y', strtotime($assign_datetime));
            $call['time_assigned'] = date('g:i a', strtotime($assign_datetime));
        }
        //end if
        $call['call_activity_diff'] = \PSU::date_diff(time(), strtotime($assign_datetime), 'simple');
        $call['call_summary'] = substr($call['comments'], 0, 100) . (strlen($call['comments']) > 100 ? '...' : '');
        $call['show_comments'] = str_replace("\"", "&#34", addslashes(substr(strip_tags(str_replace(array("\n", "\t", "\r"), '', $call['comments'])), 0, 30)));
        $call_datetime = $call['call_date'] . ' ' . $call['call_time'];
        $call['call_open_time'] = time() - strtotime($call_datetime);
        $call['call_date'] = date('M j, Y', strtotime($call_datetime));
        $call['call_time'] = date('g:i a', strtotime($call_datetime));
        if ($call['feelings_face']) {
            $call['feelings_face'] = '<br/><img src="/webapp/feedback/templates/images/feedback-' . $call['feelings_face'] . '.png" class="feedback-face" title="' . $call['feelings'] . '"/>';
        }
        //end if
//.........这里部分代码省略.........
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:101,代码来源:open_call_functions.php

示例5: _load_children

 /**
  * load children
  */
 protected function _load_children()
 {
     $this->data['children'] = array();
     $sql = "SELECT\tspriden_id,\n\t\t\t\t\t\t\t\t\t\tdecode(spriden_last_name,NULL,aprchld_first_name||' '||aprchld_mi||' '||aprchld_last_name,spriden_first_name||' '||spriden_mi||' '||spriden_last_name) aprchld_fullname,\n\t\t\t\t\t\t\t\t\t\tdecode(aprchld_birth_date,NULL,spbpers_birth_date,aprchld_birth_date) aprchld_birth_date,\n\t\t\t\t\t\t\t\t\t\tdecode(aprchld_sex,NULL,spbpers_sex,aprchld_sex) aprchld_sex,\n\t\t\t\t\t\t\t\t\t\tdecode(aprchld_deceased_ind,NULL,spbpers_dead_ind,aprchld_deceased_ind) aprchld_deceased_ind,\n\t\t\t\t\t\t\t\t\t\tdecode(aprchld_deceased_date,NULL,spbpers_dead_date,aprchld_deceased_date) aprchld_deceased_date\n\t\t\t\t\t\t\tFROM\taprchld,\n\t\t\t\t\t\t\t\t\t\tspriden,\n\t\t\t\t\t\t\t\t\t\tspbpers\n\t\t\t\t\t\t WHERE\taprchld_pidm = :pidm\n\t\t\t\t\t\t\t AND\taprchld_chld_pidm = spbpers_pidm(+)\n\t\t\t\t\t\t\t AND\taprchld_chld_pidm = spriden_pidm(+)\n\t\t\t\t\t\t\t AND\tspriden_change_ind is null";
     if ($results = \PSU::db('banner')->Execute($sql, array('pidm' => $this->pidm))) {
         foreach ($results as $row) {
             $row = \PSU::cleanKeys(array('aprchld_', 'spriden_'), '', $row);
             if ($row['birth_date']) {
                 $row['age'] = \PSU::date_diff(time(), $row['birth_date']);
             }
             $this->data['children'][] = $row;
         }
         //end foreach
     }
     //end if
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:19,代码来源:Alumni.php


注:本文中的PSU::date_diff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。