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


PHP TTDate::getTimePeriodDates方法代码示例

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


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

示例1: test_timePeriodDates

 function test_timePeriodDates()
 {
     Debug::text('Testing Time Period Dates!', __FILE__, __LINE__, __METHOD__, 10);
     TTDate::setTimeZone('PST');
     $dates = TTDate::getTimePeriodDates('custom_date', strtotime('15-Jul-10 12:00 PM'), NULL, array('start_date' => strtotime('10-Jul-10 12:43 PM'), 'end_date' => strtotime('12-Jul-10 12:43 PM')));
     $this->assertEquals($dates['start_date'], (int) 1278745200);
     $this->assertEquals($dates['end_date'], (int) 1279004399);
     $dates = TTDate::getTimePeriodDates('custom_time', strtotime('15-Jul-10 12:00 PM'), NULL, array('start_date' => strtotime('10-Jul-10 12:43 PM'), 'end_date' => strtotime('12-Jul-10 12:53 PM')));
     $this->assertEquals($dates['start_date'], (int) 1278790980);
     $this->assertEquals($dates['end_date'], (int) 1278964380);
     $dates = TTDate::getTimePeriodDates('today', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1279177200);
     $this->assertEquals($dates['end_date'], (int) 1279263599);
     $dates = TTDate::getTimePeriodDates('yesterday', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1279090800);
     $this->assertEquals($dates['end_date'], (int) 1279177199);
     $dates = TTDate::getTimePeriodDates('last_24_hours', strtotime('15-Jul-10 12:43 PM'));
     $this->assertEquals($dates['start_date'], (int) 1279136580);
     $this->assertEquals($dates['end_date'], (int) 1279222980);
     $dates = TTDate::getTimePeriodDates('this_week', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1278831600);
     $this->assertEquals($dates['end_date'], (int) 1279436399);
     $dates = TTDate::getTimePeriodDates('last_week', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1278226800);
     $this->assertEquals($dates['end_date'], (int) 1278831599);
     $dates = TTDate::getTimePeriodDates('last_7_days', strtotime('15-Jul-10 12:43 PM'));
     $this->assertEquals($dates['start_date'], (int) 1278572400);
     $this->assertEquals($dates['end_date'], (int) 1279177199);
     $dates = TTDate::getTimePeriodDates('this_month', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1277967600);
     $this->assertEquals($dates['end_date'], (int) 1280645999);
     $dates = TTDate::getTimePeriodDates('last_month', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1275375600);
     $this->assertEquals($dates['end_date'], (int) 1277967599);
     $dates = TTDate::getTimePeriodDates('last_month', strtotime('15-Mar-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1265011200);
     $this->assertEquals($dates['end_date'], (int) 1267430399);
     $dates = TTDate::getTimePeriodDates('last_30_days', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1276585200);
     $this->assertEquals($dates['end_date'], (int) 1279177199);
     $dates = TTDate::getTimePeriodDates('this_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1277967600);
     $this->assertEquals($dates['end_date'], (int) 1285916399);
     $dates = TTDate::getTimePeriodDates('last_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1270105200);
     $this->assertEquals($dates['end_date'], (int) 1277967599);
     $dates = TTDate::getTimePeriodDates('last_90_days', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1271401200);
     $this->assertEquals($dates['end_date'], (int) 1279177199);
     $dates = TTDate::getTimePeriodDates('this_year_1st_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1262332800);
     $this->assertEquals($dates['end_date'], (int) 1270105199);
     $dates = TTDate::getTimePeriodDates('this_year_2nd_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1270105200);
     $this->assertEquals($dates['end_date'], (int) 1277967599);
     $dates = TTDate::getTimePeriodDates('this_year_3rd_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1277967600);
     $this->assertEquals($dates['end_date'], (int) 1285916399);
     $dates = TTDate::getTimePeriodDates('this_year_4th_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1285916400);
     $this->assertEquals($dates['end_date'], (int) 1293868799);
     $dates = TTDate::getTimePeriodDates('last_year_1st_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1230796800);
     $this->assertEquals($dates['end_date'], (int) 1238569199);
     $dates = TTDate::getTimePeriodDates('last_year_2nd_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1238569200);
     $this->assertEquals($dates['end_date'], (int) 1246431599);
     $dates = TTDate::getTimePeriodDates('last_year_3rd_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1246431600);
     $this->assertEquals($dates['end_date'], (int) 1254380399);
     $dates = TTDate::getTimePeriodDates('last_year_4th_quarter', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1254380400);
     $this->assertEquals($dates['end_date'], (int) 1262332799);
     $dates = TTDate::getTimePeriodDates('last_3_months', strtotime('15-May-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1266134400);
     $this->assertEquals($dates['end_date'], (int) 1273906799);
     $dates = TTDate::getTimePeriodDates('last_6_months', strtotime('15-May-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1258185600);
     $this->assertEquals($dates['end_date'], (int) 1273906799);
     $dates = TTDate::getTimePeriodDates('last_9_months', strtotime('15-May-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1250233200);
     $this->assertEquals($dates['end_date'], (int) 1273906799);
     $dates = TTDate::getTimePeriodDates('last_12_months', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1247554800);
     $this->assertEquals($dates['end_date'], (int) 1279177199);
     $dates = TTDate::getTimePeriodDates('this_year', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1262332800);
     $this->assertEquals($dates['end_date'], (int) 1293868799);
     $dates = TTDate::getTimePeriodDates('last_year', strtotime('15-Jul-10 12:00 PM'));
     $this->assertEquals($dates['start_date'], (int) 1230796800);
     $this->assertEquals($dates['end_date'], (int) 1262332799);
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:92,代码来源:DateTimeTest.php

示例2: convertTimePeriodToStartEndDate

 function convertTimePeriodToStartEndDate($time_period_arr, $prefix = NULL)
 {
     Debug::Arr($time_period_arr, 'Input: Time Period Array: ', __FILE__, __LINE__, __METHOD__, 10);
     //Convert time_period into start/end date, with pay_period_schedule_ids if necessary.
     if (isset($time_period_arr['time_period']) and ($time_period_arr['time_period'] == 'custom_date' or $time_period_arr['time_period'] == 'custom_time')) {
         Debug::Text('Found Custom dates...', __FILE__, __LINE__, __METHOD__, 10);
         $retarr[$prefix . 'time_period']['time_period'] = $time_period_arr['time_period'];
         if (isset($time_period_arr['start_date'])) {
             $retarr[$prefix . 'start_date'] = TTDate::getBeginDayEpoch(TTDate::parseDateTime($time_period_arr['start_date']));
         }
         if (isset($time_period_arr['end_date'])) {
             $retarr[$prefix . 'end_date'] = TTDate::getEndDayEpoch(TTDate::parseDateTime($time_period_arr['end_date']));
         }
     } elseif (isset($time_period_arr['time_period'])) {
         $params = array();
         if (isset($time_period_arr['pay_period_schedule_id'])) {
             $params = array('pay_period_schedule_id' => $time_period_arr['pay_period_schedule_id']);
             //Make sure we keep the original array intact so we if this function is run more than once it will work each time.
             $retarr[$prefix . 'time_period']['pay_period_schedule_id'] = $time_period_arr['pay_period_schedule_id'];
         } elseif (isset($time_period_arr['pay_period_id'])) {
             $params = array('pay_period_id' => $time_period_arr['pay_period_id']);
             //Make sure we keep the original array intact so we if this function is run more than once it will work each time.
             $retarr[$prefix . 'time_period']['pay_period_id'] = $time_period_arr['pay_period_id'];
         }
         if (!isset($time_period_arr['time_period'])) {
             Debug::Text('ERROR: Time Period idenfier not specified!', __FILE__, __LINE__, __METHOD__, 10);
             $retarr[$prefix . 'time_period'] = NULL;
         } else {
             $retarr[$prefix . 'time_period']['time_period'] = $time_period_arr['time_period'];
         }
         //Debug::Arr($params, 'Time Period: '.$time_period_arr['time_period'] .' Params: ', __FILE__, __LINE__, __METHOD__,10);
         $time_period_dates = TTDate::getTimePeriodDates($time_period_arr['time_period'], NULL, $this->getUserObject(), $params);
         if ($time_period_dates != FALSE) {
             if (isset($time_period_dates['start_date'])) {
                 $retarr[$prefix . 'start_date'] = $time_period_dates['start_date'];
             }
             if (isset($time_period_dates['end_date'])) {
                 $retarr[$prefix . 'end_date'] = $time_period_dates['end_date'];
             }
             if (isset($time_period_dates['pay_period_id'])) {
                 $retarr[$prefix . 'pay_period_id'] = $time_period_dates['pay_period_id'];
             }
         } else {
             //No pay period find default to no time period, otherwise the report can take forever to finish.
             Debug::Text('No pay periods found, defaulting to none (0)...', __FILE__, __LINE__, __METHOD__, 10);
             $retarr[$prefix . 'pay_period_id'] = 0;
             //This can actually find data not assigned to a pay period.
         }
     } else {
         Debug::Text('Invalid TimePeriod filter...', __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     Debug::Arr($retarr, 'Output: Time Period Array: ', __FILE__, __LINE__, __METHOD__, 10);
     return $retarr;
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:55,代码来源:Report.class.php


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