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


PHP DateTimeValueLib::get_time_difference方法代码示例

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


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

示例1: friendly_date

function friendly_date(DateTimeValue $date, $timezone = null)
{
    if ($timezone == null) {
        $timezone = logged_user()->getTimezone();
    }
    //TODO: 7 days before: "Dom at 13:43", older: "Oct, 06 at 15:20"
    if ($date->isToday()) {
        $now = DateTimeValueLib::now();
        $diff = DateTimeValueLib::get_time_difference($date->getTimestamp(), $now->getTimestamp());
        if ($diff['hours'] == 0) {
            if ($diff['minutes'] >= 0) {
                return lang('minutes ago', $diff['minutes']);
            } else {
                return format_descriptive_date($date);
            }
        } else {
            if ($diff['hours'] > 0) {
                return lang('about hours ago', round($diff['hours'] + ($diff['minutes'] > 30 ? 1 : 0)));
            } else {
                return format_descriptive_date($date);
            }
        }
    } else {
        if ($date->isYesterday()) {
            return lang('yesterday at', format_time($date));
        } else {
            $now = DateTimeValueLib::now();
            $diff = DateTimeValueLib::get_time_difference($date->getTimestamp(), $now->getTimestamp());
            if ($diff['days'] < 7) {
                return lang('day at', Localization::dateByLocalization("D", $date->getTimestamp()), format_time($date));
            } else {
                if ($now->getYear() != $date->getYear()) {
                    return lang('day at', Localization::dateByLocalization("M d, Y", $date->getTimestamp()), format_time($date));
                } else {
                    return lang('day at', Localization::dateByLocalization("M, d", $date->getTimestamp()), format_time($date));
                }
            }
        }
    }
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:40,代码来源:format.php

示例2: DateTimeValue

     $occup[$event_start->getHour()][1][$posHoriz] = true;
 }
 for ($i = $event_start->getHour() + 1; $i < $event_duration->getHour(); $i++) {
     $occup[$i][0][$posHoriz] = true;
     $occup[$i][1][$posHoriz] = true;
 }
 if ($event_duration->getMinute() > 0) {
     $occup[$event_duration->getHour()][0][$posHoriz] = true;
     if ($event_duration->getMinute() > 30) {
         $occup[$event_duration->getHour()][1][$posHoriz] = true;
     }
 }
 //if ($posHoriz+1 == $evs_same_time) $width = $width - 0.75;
 $procesados[$hr_start]++;
 $event_duration->add('s', 1);
 $ev_duration = DateTimeValueLib::get_time_difference($event_start->getTimestamp(), $event_duration->getTimestamp());
 if ($event instanceof ProjectEvent) {
     $real_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone());
     $real_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone());
 } else {
     if ($event instanceof ProjectTask) {
         if ($event->getStartDate() instanceof DateTimeValue) {
             $real_start = new DateTimeValue($event->getStartDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
         } else {
             $real_start = $event_start;
         }
         if ($event->getDueDate() instanceof DateTimeValue) {
             $real_duration = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone());
         } else {
             $real_duration = $event_duration;
         }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:31,代码来源:viewdate.php

示例3: move_event

	function move_event() {
		if (logged_user()->isGuest()) {
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
		}
		$event = ProjectEvents::findById(get_id());
		if(!$event->canEdit(logged_user())){	    	
			flash_error(lang('no access permissions'));
			ajx_current("empty");
			return;
	    }
	    $is_read = $event->getIsRead(logged_user()->getId());
		
	    $year = array_var($_GET, 'year', $event->getStart()->getYear());
	    $month = array_var($_GET, 'month', $event->getStart()->getMonth());
	    $day = array_var($_GET, 'day', $event->getStart()->getDay());
	    $hour = array_var($_GET, 'hour', 0);
	    $min = array_var($_GET, 'min', 0);
	    
	    if ($hour == -1) $hour = format_date($event->getStart(), 'H', logged_user()->getTimezone() );
	    if ($min == -1) $min = format_date($event->getStart(), 'i', logged_user()->getTimezone() );
	    
		if ($event->isRepetitive()) {
			$orig_date = DateTimeValueLib::dateFromFormatAndString('Y-m-d H:i:s', array_var($_GET, 'orig_date'));
			$diff = DateTimeValueLib::get_time_difference($orig_date->getTimestamp(), mktime($hour, $min, 0, $month, $day, $year));
		    $new_start = new DateTimeValue($event->getStart()->getTimestamp());
		    $new_start->add('d', $diff['days']);
		    $new_start->add('h', $diff['hours']);
		    $new_start->add('m', $diff['minutes']);
		    
		    if ($event->getRepeatH()) {
		    	$event->setRepeatDow(date("w", mktime($hour, $min, 0, $month, $day, $year))+1);
		    	$wnum = 0;
		    	$tmp_day = $new_start->getDay();
		    	while ($tmp_day > 0) {
		    		$tmp_day -= 7;
		    		$wnum++;
		    	}
		    	$event->setRepeatWnum($wnum);
		    }
	    } else {
		    $new_start = new DateTimeValue(mktime($hour, $min, 0, $month, $day, $year) - logged_user()->getTimezone() * 3600);
	    }

	    $diff = DateTimeValueLib::get_time_difference($event->getStart()->getTimestamp(), $event->getDuration()->getTimestamp());
	    $new_duration = new DateTimeValue($new_start->getTimestamp());
	    $new_duration->add('d', $diff['days']);
	    $new_duration->add('h', $diff['hours']);
	    $new_duration->add('m', $diff['minutes']);
	    
	    // see if we have to reload
		$os = format_date($event->getStart(), 'd', logged_user()->getTimezone() );
		$od = format_date($event->getDuration(), 'd', logged_user()->getTimezone() );
		$ohm = format_date($event->getDuration(), 'H:i', logged_user()->getTimezone() );
		$nd = format_date($new_duration, 'd', logged_user()->getTimezone() );
		$nhm = format_date($new_duration, 'H:i', logged_user()->getTimezone() );
		$different_days = ($os != $od && $ohm != '00:00') || ($day != $nd && $nhm != '00:00');
	    
        DB::beginWork();
	    $event->setStart($new_start->format("Y-m-d H:i:s"));
	    $event->setDuration($new_duration->format("Y-m-d H:i:s"));
	    $event->save();
		
	    $old_reminders = ObjectReminders::getByObject($event);	    
		if($old_reminders != null){		
			$object_controller = new ObjectController();								
			$object_controller->update_reminders($event, $old_reminders); //updating the old ones			
		}else if(user_config_option("add_event_autoreminder")){
			$reminder = new ObjectReminder();
			$def = explode(",",user_config_option("reminders_events"));
			$minutes = array_var($def, 2) * array_var($def, 1);
          	$reminder->setMinutesBefore($minutes);
            $reminder->setType(array_var($def, 0));
            $reminder->setContext("start");
            $reminder->setObject($event);
            $reminder->setUserId(0);
            $date = $event->getStart();
			if ($date instanceof DateTimeValue) {
				$rdate = new DateTimeValue($date->getTimestamp() - $minutes * 60);
				$reminder->setDate($rdate);
			}
			$reminder->save();
		}
        if (!$is_read) {
            $event->setIsRead(logged_user()->getId(), false);
        }
        if($event->getSpecialID() != ""){
            $this->sync_calendar_extern($event);
        }
            
	    DB::commit();
    
	    ajx_extra_data($this->get_updated_event_data($event));
	    if ($different_days || $event->isRepetitive()) ajx_current("reload");
	    else ajx_current("empty");
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:97,代码来源:EventController.class.php

示例4: getSecondsSincePause

 function getSecondsSincePause(){
 	if (!$this->getPausedOn())
 		return 0;
 		
 	$endTime = DateTimeValueLib::now();
 	$timeDiff = DateTimeValueLib::get_time_difference($this->getPausedOn()->getTimestamp(),$endTime->getTimestamp());
 	
 	return $timeDiff['days'] * 86400 + $timeDiff['hours'] * 3600  + $timeDiff['minutes']* 60 + $timeDiff['seconds'];
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:9,代码来源:Timeslot.class.php

示例5: updateBillingValues

 static function updateBillingValues()
 {
     $timeslot_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "timeslots WHERE `end_time` > 0 AND billing_id = 0 AND is_fixed_billing = 0");
     $users = Contacts::getAllUsers();
     $usArray = array();
     foreach ($users as $u) {
         $usArray[$u->getId()] = $u;
     }
     $count = 0;
     $categories_cache = array();
     foreach ($timeslot_rows as $ts_row) {
         if ($ts_row['start_time'] == EMPTY_DATETIME) {
             $ts_row['minutes'] = 0;
         } else {
             $startTime = DateTimeValueLib::makeFromString($ts_row['start_time']);
             if ($ts_row['start_time'] == EMPTY_DATETIME) {
                 $endTime = $ts_row['is_paused'] ? DateTimeValueLib::makeFromString($ts_row['paused_on']) : DateTimeValueLib::now();
             } else {
                 $endTime = DateTimeValueLib::makeFromString($ts_row['end_time']);
             }
             $timeDiff = DateTimeValueLib::get_time_difference($startTime->getTimestamp(), $endTime->getTimestamp(), $ts_row['subtract']);
             $ts_row['minutes'] = $timeDiff['days'] * 1440 + $timeDiff['hours'] * 60 + $timeDiff['minutes'];
         }
         $user = $usArray[$ts_row['contact_id']];
         if ($user instanceof Contact) {
             $billing_category_id = $user->getDefaultBillingId();
             if ($billing_category_id > 0) {
                 $hours = $ts_row['minutes'] / 60;
                 $billing_category = array_var($categories_cache, $billing_category_id);
                 if (!$billing_category instanceof BillingCategory) {
                     $billing_category = BillingCategories::findById($billing_category_id);
                     $categories_cache[$billing_category_id] = $billing_category;
                 }
                 if ($billing_category instanceof BillingCategory) {
                     $hourly_billing = $billing_category->getDefaultValue();
                     DB::execute("UPDATE " . TABLE_PREFIX . "timeslots SET billing_id='{$billing_category_id}', hourly_billing='{$hourly_billing}', \r\n\t\t\t\t\t\t\tfixed_billing='" . round($hourly_billing * $hours, 2) . "', is_fixed_billing=0 \r\n\t\t\t\t\t\t\tWHERE object_id=" . $ts_row['object_id']);
                     $count++;
                 }
             }
         } else {
             DB::execute("UPDATE " . TABLE_PREFIX . "timeslots SET is_fixed_billing=1 WHERE object_id=" . $ts_row['object_id']);
         }
     }
     return $count;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:45,代码来源:Timeslots.class.php

示例6: move_event

 function move_event()
 {
     if (logged_user()->isGuest()) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $event = ProjectEvents::findById(get_id());
     if (!$event->canEdit(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     $is_read = $event->getIsRead(logged_user()->getId());
     $year = array_var($_GET, 'year', $event->getStart()->getYear());
     $month = array_var($_GET, 'month', $event->getStart()->getMonth());
     $day = array_var($_GET, 'day', $event->getStart()->getDay());
     $hour = array_var($_GET, 'hour', 0);
     $min = array_var($_GET, 'min', 0);
     if ($hour == -1) {
         $hour = format_date($event->getStart(), 'H', logged_user()->getTimezone());
     }
     if ($min == -1) {
         $min = format_date($event->getStart(), 'i', logged_user()->getTimezone());
     }
     if ($event->isRepetitive()) {
         $orig_date = DateTimeValueLib::dateFromFormatAndString('Y-m-d H:i:s', array_var($_GET, 'orig_date'));
         $diff = DateTimeValueLib::get_time_difference($orig_date->getTimestamp(), mktime($hour, $min, 0, $month, $day, $year));
         $new_start = new DateTimeValue($event->getStart()->getTimestamp());
         $new_start->add('d', $diff['days']);
         $new_start->add('h', $diff['hours']);
         $new_start->add('m', $diff['minutes']);
         if ($event->getRepeatH()) {
             $event->setRepeatDow(date("w", mktime($hour, $min, 0, $month, $day, $year)) + 1);
             $wnum = 0;
             $tmp_day = $new_start->getDay();
             while ($tmp_day > 0) {
                 $tmp_day -= 7;
                 $wnum++;
             }
             $event->setRepeatWnum($wnum);
         }
     } else {
         $new_start = new DateTimeValue(mktime($hour, $min, 0, $month, $day, $year) - logged_user()->getTimezone() * 3600);
     }
     $diff = DateTimeValueLib::get_time_difference($event->getStart()->getTimestamp(), $event->getDuration()->getTimestamp());
     $new_duration = new DateTimeValue($new_start->getTimestamp());
     $new_duration->add('d', $diff['days']);
     $new_duration->add('h', $diff['hours']);
     $new_duration->add('m', $diff['minutes']);
     // see if we have to reload
     $os = format_date($event->getStart(), 'd', logged_user()->getTimezone());
     $od = format_date($event->getDuration(), 'd', logged_user()->getTimezone());
     $ohm = format_date($event->getDuration(), 'H:i', logged_user()->getTimezone());
     $nd = format_date($new_duration, 'd', logged_user()->getTimezone());
     $nhm = format_date($new_duration, 'H:i', logged_user()->getTimezone());
     $different_days = $os != $od && $ohm != '00:00' || $day != $nd && $nhm != '00:00';
     DB::beginWork();
     $event->setStart($new_start->format("Y-m-d H:i:s"));
     $event->setDuration($new_duration->format("Y-m-d H:i:s"));
     $event->save();
     if (!$is_read) {
         $event->setIsRead(logged_user()->getId(), false);
     }
     if ($event->getSpecialID() != "") {
         $this->sync_calendar_extern($event);
     }
     DB::commit();
     ajx_extra_data($this->get_updated_event_data($event));
     if ($different_days || $event->isRepetitive()) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:75,代码来源:EventController.class.php


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