makeWindows()

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2012-10-29

@param  int  $num_days from now

@return array of newly created SellerWindows
173115
public function makeWindows($num_days = 14)
    {
        $newWindows = array();

        foreach ($this->getDateAdjustedStartTimes(new \DateTime(), $num_days) as $startTime)
        {
            // If window doesn't already exist for this time
            if (!$this->getSellerHubRef()->getSellerWindowAtThisTime($startTime, $this->getDeliveryType()))
            {
                // We must have a HubWindow
                if ($hubWindow = $this->getHub()->getHubWindowAtThisTime($startTime, $this->getDeliveryType()))
                {
                    // Create a new window
                    $window = $this->getNewWindow();
                    $window->setStartTime($startTime);
                    $window->setEndTime($this->getEndTimeFromStartTime($startTime));

                    // Connect it to HubWindow
                    $hubWindow->addSellerWindow($window);

                    // Add it to array of new windows
                    $newWindows[] = $window;

                    // Add it as a relation of this WindowMaker
                    $this->addSellerWindow($window);
                }
                else
                {
#                    exit('HubWindow does not exist at '.$startTime->format(\DateTime::ATOM));
                }
            }
        }

        $this->setLastRunAt(new \DateTime());

        return $newWindows;
    }
706735
private function makeStartingTimestamp($window, $timestamp, $oldTimestamp)
    {
        return $oldTimestamp === Constants::ARGUMENT_NOT_SET
            ? $timestamp - $this->getWindow($window)
            : max($timestamp - $this->getWindow($window), $oldTimestamp + 1);
    }
624314
public function generateAvailability($startDate = 'today', $futureDays = 10)
    {
        $dates = [];
        for ($i = 0; $i < $futureDays; $i++) {
            $dates[date('Y-m-d', strtotime("$startDate +$i days"))] = [];
        }

        foreach ($this->business->vacancies as $vacancy) {
            if (array_key_exists($vacancy->date, $dates)) {
                $dates[$vacancy->date][$vacancy->service->slug] = $vacancy;
            }
        }

        return $dates;
    }
1326875
def batchWindows(windows, batchSize):
	
	return np.array_split(np.array(windows), len(windows) // batchSize)
398532
public function makeAction(SellerWindowMaker $windowMaker)
    {
        $windows = $windowMaker->makeWindows();

        $em = $this->getDoctrine()->getEntityManager();
        $em->persist($windowMaker);
        $em->flush();

        return $this->redirect($this->generateUrl('Seller_window_maker_show', array(
            'id' => $windowMaker->getId(),
        )));
    }
624835
public function generateSlots()
    {
        $interval = $this->startDate->diff($this->endDate);

        foreach (array_keys(WindowMaker::getStartTimeChoices()) as $hour)
        {
            $time = array(
                'label'     => $hour.':00 - '.($hour+2).':00',
                'time_key'  => $hour.':00',
                'days'      => array(),
            );

            $day = new \DateTime($this->startDate->format('Y-m-d '.$time['time_key']));;

            for ($i=0; $i<$interval->days+1; $i++)
            {
                if ($i)
                {
                    $day->add(new \DateInterval('P1D'));
                }

                $time['days'][] = array(
                    'dateTime' => clone $day,
                    'objects'  => array(),
                );
            }

            $this->slots['times'][] = $time;
        }

        return $this->slots;
    }
366270
public function runInBackground(DateTime $now = null) : array
    {
        $jobs = $this->getDueJobs($now);

        foreach ($jobs as $job) {
            $this->processes[] = $job->runInBackground();
        }

        return $this->processes;
    }
1005823
function aboutSessionRestore_getWindows() {
    var windows = [ ];
    var tree = this.tabList.getNode();

    for (var ii = 0; ii < tree.view.rowCount; ii++) {
      if (tree.view.isContainer(ii)) {
        windows.push({
                      index: windows.length,
                      listIndex : ii,
                      open: tree.view.isContainerOpen(ii),
                      restore: tree.view.getCellValue(ii, tree.columns.getColumnAt(0)),
                      title: tree.view.getCellText(ii, tree.columns.getColumnAt(2))
                     });
      }
    }

    return windows;
  }
423934
public function getNewWindow()
    {
        switch ($this->getDeliveryType())
        {
            case HubWindow::DELIVERY_TYPE_PICKUP:

              $window = new SellerPickupWindow();

              break;

            case HubWindow::DELIVERY_TYPE_DELIVERY:

              $window = new SellerDeliveryWindow();

              break;
        }

        $this->getSellerHubRef()->addSellerWindow($window);

        return $window;
    }
1194903
public static function dayToNow($day = 1, $now = true)
    {
        $end = time();
        if (!$now) {
            list($foo, $end) = self::yesterday();
        }

        return [
            mktime(0, 0, 0, date('m'), date('d') - $day, date('Y')),
            $end
        ];
    }
521685
public function batchSize($num)
    {
        $this->batchSize = (integer) $num;
        $this->riakCommandCursor->batchSize($num);

        return $this;
    }
937108
public function listDirectDeals($optParams = array()) {
      $params = array();
      $params = array_merge($params, $optParams);
      $data = $this->__call('list', array($params));
      if ($this->useObjects()) {
        return new DirectDealsList($data);
      } else {
        return $data;
      }
    }
1155066
public function indexAction()
    {
        $currentProfile = $this->getCurrentProfile();

        $windowMakers = $this->getRepo('SellerWindowMaker')
            ->findForSeller($currentProfile)
        ;

        return $this->render('HarvestCloudCoreBundle:Seller/WindowMaker:index.html.twig', array(
          'windowMakers' => $windowMakers,
        ));
    }
456190
private function _buildDates()
    {
        if ( !$this->from || !$this->to || $this->from > $this->to ) {
            return;
        }
        $this->dates = array();
        $d = clone $this->from;
        $this->dates[] = clone $d;
        while ( $d != $this->to ) {
            $d->add(new \DateInterval('P1D'));
            $this->dates[] = clone $d;
        }
    }
978720
function DaysToNow(){ // as datetime object returns difference in seconds
		if(empty(self::$dtnow)){
			self::$dtnow=new \DateTime();
			}
		//Get difference
		$diff=$this->diff(self::$dtnow);
		$diff_days =$diff->format('%r').($diff->days);
		return $diff_days;
		}
425144
public static function addDay($ts = null, $num = 1)
	{
		return sfTime::add($ts, $num, sfTime::DAY);
	}
1092634
public static function create($nRows, $nColumns) {
    $emptyRow = $nColumns
      ? array_fill(0, $nColumns, new PlaceholderCell())
      : [];
    return new static($nRows, $emptyRow);
  }