コード例 #1
0
 private function inIntervalStatement(TimeInterval $interval)
 {
     $start_date = $this->da->escapeInt($interval->getStartTimestamp());
     $end_date = $this->da->escapeInt($interval->getEndTimestamp());
     $sql = "AND date >= {$start_date}\n                AND date <= {$end_date}";
     return $sql;
 }
コード例 #2
0
function AddTimeCredit($merchantAutobillId, $daysRemaining)
{
    $autoBill = new AutoBill();
    $autoBill->setMerchantAutoBillId($merchantAutobillId);
    $timeInterval = new TimeInterval();
    $timeInterval->setDays($daysRemaining);
    $timeInterval->setDescription("Early Pay on NonRecurring Billing");
    $timeInterval->setReason("Credit for July");
    $cr = new Credit();
    $cr->setTimeIntervals(array($timeInterval));
    $response = $autoBill->grantCredit($cr, '');
    logCall($response, 'AutoBill::GrantCredit', $daysRemaining);
}
コード例 #3
0
 private function assertInvalidIntervalTimestamps($start, $end)
 {
     try {
         TimeInterval::fromUnixTimestamps($start, $end);
         $this->fail('should have thrown exception');
     } catch (Exception $exc) {
     }
 }
コード例 #4
0
 /**
  * @return void
  */
 public function Validate()
 {
     try {
         TimeInterval::Parse($this->value);
     } catch (Exception $ex) {
         $this->isValid = false;
         $this->AddMessage("Invalid time specified for {$this->attributeName}");
     }
 }
コード例 #5
0
 static function __static()
 {
     self::$YEAR = new self(0, 'year');
     self::$MONTH = new self(1, 'month');
     self::$DAY = new self(2, 'day');
     self::$HOURS = new self(3, 'hours');
     self::$MINUTES = new self(4, 'minutes');
     self::$SECONDS = new self(5, 'seconds');
 }
コード例 #6
0
ファイル: ReservationSeries.php プロジェクト: JoseTfg/Booked
 /**
  * @return TimeInterval|null
  */
 public function MaxBufferTime()
 {
     $max = new TimeInterval(0);
     foreach ($this->AllResources() as $resource) {
         if ($resource->HasBufferTime()) {
             $buffer = $resource->GetBufferTime();
             if ($buffer->TotalSeconds() > $max->TotalSeconds()) {
                 $max = $buffer;
             }
         }
     }
     return $max->TotalSeconds() > 0 ? $max : null;
 }
コード例 #7
0
ファイル: Date.php プロジェクト: hugutux/booked
 /**
  * @param TimeInterval $interval
  * @return Date
  */
 public function AddInterval(TimeInterval $interval)
 {
     return $this->ApplyDifference($interval->Diff());
 }
コード例 #8
0
ファイル: BookableResource.php プロジェクト: hugutux/booked
 /**
  * @return TimeInterval
  */
 public function GetBufferTime()
 {
     return TimeInterval::Parse($this->_bufferTime);
 }
コード例 #9
0
 /**
  * Return top most modified files during the given period
  * 
  * @param String  $sessionKey Session key of the requesting user
  * @param Integer $group_id    ID of the project the subversion repository belongs to
  * @param Integer $start_date  Start of period (unix timestamp)
  * @param Integer $end_date    End of period   (unix timestamp)
  * @param Integer $limit       Max number of files to return
  * 
  * @return ArrayOfSvnPathInfo
  */
 public function getSvnStatsFiles($sessionKey, $group_id, $start_date, $end_date, $limit)
 {
     try {
         $current_user = $this->soap_request_validator->continueSession($sessionKey);
         $project = $this->soap_request_validator->getProjectById($group_id, 'getSvnStatsFiles');
         $this->soap_request_validator->assertUserCanAccessProject($current_user, $project);
         $svn_log = new SVN_LogFactory($project);
         $files = $svn_log->getTopModifiedFiles($current_user, TimeInterval::fromUnixTimestamps($start_date, $end_date), $limit);
         return $files;
     } catch (Exception $e) {
         return new SoapFault((string) $e->getCode(), $e->getMessage());
     }
 }
コード例 #10
0
ファイル: ReportColumn.php プロジェクト: JoseTfg/Booked
 public function GetData($data)
 {
     $interval = new TimeInterval($data);
     return $interval->ToString(true);
 }
コード例 #11
0
 public function testBindsDatesWhenResourceHasMinimumTime()
 {
     $timezone = 'UTC';
     $scheduleId = 1;
     $dateString = Date::Now()->AddDays(1)->SetTimeString('02:55:22')->Format('Y-m-d H:i:s');
     $endDateString = Date::Now()->AddDays(1)->SetTimeString('4:55:22')->Format('Y-m-d H:i:s');
     $dateInUserTimezone = Date::Parse($dateString, $timezone);
     $startDate = Date::Parse($dateString, $timezone);
     $endDate = Date::Parse($endDateString, $timezone);
     $expectedEndDate = $startDate->AddHours(2);
     $resourceDto = new ResourceDto(1, 'resource', true, $scheduleId, TimeInterval::FromHours(2));
     $this->initializer->expects($this->any())->method('CurrentUser')->will($this->returnValue($this->fakeUser));
     $this->initializer->expects($this->any())->method('GetTimezone')->will($this->returnValue($timezone));
     $this->initializer->expects($this->any())->method('GetReservationDate')->will($this->returnValue($dateInUserTimezone));
     $this->initializer->expects($this->any())->method('GetStartDate')->will($this->returnValue($startDate));
     $this->initializer->expects($this->any())->method('GetEndDate')->will($this->returnValue($endDate));
     $this->initializer->expects($this->any())->method('GetScheduleId')->will($this->returnValue($scheduleId));
     $this->initializer->expects($this->any())->method('PrimaryResource')->will($this->returnValue($resourceDto));
     $startPeriods = array(new SchedulePeriod(Date::Now(), Date::Now()));
     $endPeriods = array(new SchedulePeriod(Date::Now()->AddDays(1), Date::Now()->AddDays(1)));
     $layout = $this->getMock('IScheduleLayout');
     $this->scheduleRepository->expects($this->once())->method('GetLayout')->with($this->equalTo($scheduleId), $this->equalTo(new ReservationLayoutFactory($timezone)))->will($this->returnValue($layout));
     $layout->expects($this->at(0))->method('GetLayout')->with($this->equalTo($startDate))->will($this->returnValue($startPeriods));
     $layout->expects($this->at(1))->method('GetLayout')->with($this->equalTo($endDate))->will($this->returnValue($endPeriods));
     $this->initializer->expects($this->once())->method('SetDates')->with($this->equalTo($startDate), $this->equalTo($expectedEndDate), $this->equalTo($startPeriods), $this->equalTo($endPeriods));
     $this->initializer->expects($this->once())->method('HideRecurrence')->with($this->equalTo(false));
     $this->initializer->expects($this->once())->method('IsNew')->will($this->returnValue(true));
     $binder = new ReservationDateBinder($this->scheduleRepository);
     $binder->Bind($this->initializer);
 }
コード例 #12
0
 /**
  * Sets new date format
  *
  * @see http://www.php.net/manual/en/function.date.php
  * @param string $format new date format to use
  * @return void
  */
 public static function setFormat($format)
 {
     self::$format = (string) $format;
 }
コード例 #13
0
 /**
  * @return TimeInterval
  */
 public function GetBufferTime()
 {
     return TimeInterval::Parse($this->bufferSeconds);
 }
コード例 #14
0
ファイル: ResourceResponse.php プロジェクト: hugutux/booked
 public function __construct()
 {
     $interval = new TimeInterval(120);
     $length = $interval->__toString();
     $this->resourceId = 123;
     $this->name = 'resource name';
     $this->location = 'location';
     $this->contact = 'contact';
     $this->notes = 'notes';
     $this->maxLength = $length;
     $this->minLength = $length;
     $this->maxNotice = $length;
     $this->minNotice = $length;
     $this->requiresApproval = true;
     $this->allowMultiday = true;
     $this->maxParticipants = 10;
     $this->description = 'resource description';
     $this->scheduleId = 123;
     $this->statusId = ResourceStatus::AVAILABLE;
     $this->statusReasonId = 3;
     $this->customAttributes = array(CustomAttributeResponse::Example());
 }
コード例 #15
0
ファイル: TimeInterval.php プロジェクト: hugutux/booked
 /**
  * @param $days
  * @return TimeInterval
  */
 public static function FromDays($days)
 {
     return TimeInterval::Parse($days * 60 * 60 * 24);
 }
コード例 #16
0
 public function testOrdersAndFormatsData()
 {
     $timezone = 'America/Chicago';
     $date = '2012-02-14 08:12:31';
     $oneHourThirtyMinutes = TimeInterval::Parse("1h30m");
     $userId = 100;
     $rows = array(array(ColumnNames::RESERVATION_START => $date, ColumnNames::OWNER_FULL_NAME_ALIAS => 'un', ColumnNames::OWNER_USER_ID => $userId, ColumnNames::ACCESSORY_NAME => 'an', 'unknown' => 'unknown', ColumnNames::TOTAL_TIME => $oneHourThirtyMinutes->TotalSeconds(), ColumnNames::ACCESSORY_ID => 1));
     $report = new CustomReport($rows, $this->attributeRepository);
     $definition = new ReportDefinition($report, $timezone);
     /** @var $row ReportCell[] */
     $row = $definition->GetRow($rows[0]);
     $this->assertEquals(4, count($row));
     $this->assertEquals('an', $row[0]->Value());
     $format = Resources::GetInstance()->GeneralDateTimeFormat();
     $systemFormat = Resources::GetInstance()->GeneralDateFormat();
     $this->assertEquals(Date::FromDatabase($date)->ToTimezone($timezone)->Format($format), $row[1]->Value());
     $this->assertEquals(Date::FromDatabase($date)->ToTimezone($timezone)->Format($systemFormat), $row[1]->ChartValue());
     $this->assertEquals(ChartColumnType::Date, $row[1]->GetChartColumnType());
     $this->assertNull($row[1]->GetChartGroup());
     $this->assertEquals('un', $row[2]->Value());
     $this->assertEquals($userId, $row[2]->ChartValue());
     $this->assertEquals(ChartColumnType::Label, $row[2]->GetChartColumnType());
     $this->assertEmpty($row[2]->GetChartGroup());
     $this->assertEquals($oneHourThirtyMinutes, $row[3]->Value());
     $this->assertEquals($oneHourThirtyMinutes->TotalSeconds(), $row[3]->ChartValue());
     $this->assertEquals(ChartColumnType::Total, $row[3]->GetChartColumnType());
 }
コード例 #17
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct(new Time(0, 0, 0), new Time(24, 0, 0));
 }
コード例 #18
0
 protected function setOpeningIntervals(array $openingIntervals)
 {
     if (empty($openingIntervals)) {
         throw new \InvalidArgumentException('The day must have at least one opening interval.');
     }
     $this->openingIntervals = [];
     foreach ($openingIntervals as $openingInterval) {
         if (!is_array($openingInterval) || !isset($openingInterval[0]) || !isset($openingInterval[1])) {
             throw new \InvalidArgumentException('Each interval must be an array containing opening and closing times.');
         }
         $this->openingIntervals[] = TimeInterval::fromString($openingInterval[0], $openingInterval[1]);
     }
     usort($this->openingIntervals, function (TimeInterval $a, TimeInterval $b) {
         return $a->getStart() > $b->getStart() ? 1 : -1;
     });
 }
コード例 #19
0
ファイル: DateTests.php プロジェクト: utn-frm-si/booked
 public function testTimeIntervalParsesEmptyValue()
 {
     $interval = TimeInterval::Parse('dhm');
     $this->assertEquals(0, $interval->TotalSeconds());
 }
コード例 #20
0
ファイル: Commands.php プロジェクト: ksdtech/booked
 public function __construct($id, $name, $location, $contact, $notes, TimeInterval $minDuration, TimeInterval $maxDuration, $autoAssign, $requiresApproval, $allowMultiday, $maxParticipants, TimeInterval $minNoticeTime, TimeInterval $maxNoticeTime, $description, $imageName, $scheduleId, $adminGroupId, $allowCalendarSubscription, $publicId, $sortOrder, $resourceTypeId, $statusId, $reasonId, TimeInterval $bufferTime)
 {
     parent::__construct(Queries::UPDATE_RESOURCE);
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_ID, $id));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_NAME, $name));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_LOCATION, $location));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_CONTACT, $contact));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_DESCRIPTION, $description));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_NOTES, $notes));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_MINDURATION, $minDuration->ToDatabase()));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_MAXDURATION, $maxDuration->ToDatabase()));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_AUTOASSIGN, $autoAssign));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_REQUIRES_APPROVAL, $requiresApproval));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_ALLOW_MULTIDAY, $allowMultiday));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_MAX_PARTICIPANTS, $maxParticipants));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_MINNOTICE, $minNoticeTime->ToDatabase()));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_MAXNOTICE, $maxNoticeTime->ToDatabase()));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_IMAGE_NAME, $imageName));
     $this->AddParameter(new Parameter(ParameterNames::SCHEDULE_ID, $scheduleId));
     $this->AddParameter(new Parameter(ParameterNames::GROUP_ADMIN_ID, $adminGroupId));
     $this->AddParameter(new Parameter(ParameterNames::ALLOW_CALENDAR_SUBSCRIPTION, (int) $allowCalendarSubscription));
     $this->AddParameter(new Parameter(ParameterNames::PUBLIC_ID, $publicId));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_SORT_ORDER, $sortOrder));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_TYPE_ID, empty($resourceTypeId) ? null : $resourceTypeId));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_STATUS, $statusId));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_STATUS_REASON_ID, $reasonId));
     $this->AddParameter(new Parameter(ParameterNames::RESOURCE_BUFFER_TIME, $bufferTime->ToDatabase()));
 }
コード例 #21
0
ファイル: TimeInterval.php プロジェクト: rouffj/timemachine
 public function isEquals(TimeInterval $interval)
 {
     return $this->begin->isEquals($interval->getBegin()) && $this->end->isEquals($interval->getEnd());
 }