See https://wakatime.com/developers#durations for details.

@param  [type] $date
@param  string $project
@param  string $branches
@return [type]
778623
public function durations($date, $project = null, $branches = NULL)
    {
        if ($project !== null) {
            $project = "&project={$project}";
        }

        if ($branches !== null) {
            $branches = "&branches={$branches}";
        }

        return $this->makeRequest("users/current/durations?date={$date}" . $project . $branches);
    }
518914
public function deployDeploy(
        $stage,
        $branchOrTag,
        $opts = [
            self::OPT_DEPLOYER_PARALLEL => false,
        ]
    ) {
        // use string parallel due as robo always submits this string for both triggers
        $parallelMode = $opts['parallel'];

        $this->startTimer();

        $this->printStageInfo('DEPLOYER DEPLOY');

        $task = $this->taskDeployerDeploy($stage, $branchOrTag);
        if ($parallelMode === true) {
            $task->parallel();
        }

        $task->run();

        $this->stopTimer();
        $this->printRuntime(__FUNCTION__);
    }
356979
protected function configureBranchPackage($branch, array $data)
    {
        $parsedBranch = $this->versionParser->normalizeBranch($branch);
        $data['version_normalized'] = $parsedBranch;

        // make sure branch packages have a dev flag
        if ('dev-' === substr((string) $parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) {
            $data['version'] = 'dev-'.$data['version'];
        } else {
            $data['version'] = preg_replace('{(\.9{7})+}', '.x', (string) $parsedBranch);
        }

        return $data;
    }
678244
public function publishBase($branch = null, $tag = null)
    {
        if (!$branch) {
            $branch = self::STABLE_BRANCH;
        }

        $this->say("Updating Codeception Base distribution");

        $tempBranch = "tmp".uniqid();

        $this->taskGitStack()
            ->checkout("-b $tempBranch")
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->from('"codeception/codeception"')
            ->to('"codeception/base"')
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->regex('~^\s+"facebook\/webdriver".*$~m')
            ->to('')
            ->run();

        $this->taskReplaceInFile('composer.json')
            ->regex('~^\s+"guzzlehttp\/guzzle".*$~m')
            ->to('')
            ->run();

        $this->taskComposerUpdate()->run();
        $this->taskGitStack()
            ->add('composer.json')
            ->commit('auto-update')
            ->exec("push -f base $tempBranch:$branch")
            ->run();

        if ($tag) {
            $this->taskGitStack()
                ->exec("tag -d $tag")
                ->exec("push base :refs/tags/$tag")
                ->exec("tag $tag")
                ->push('base', $tag)
                ->run();
        }

        $this->taskGitStack()
            ->checkout('-- composer.json')
            ->checkout($branch)
            ->exec("branch -D $tempBranch")
            ->run();
    }
828313
private void readException(ProjectCalendar bc, Project.Calendars.Calendar.Exceptions.Exception exception)
   {
      Date fromDate = exception.getTimePeriod().getFromDate();
      Date toDate = exception.getTimePeriod().getToDate();

      // Vico Schedule Planner seems to write start and end dates to FromTime and ToTime
      // rather than FromDate and ToDate. This is plain wrong, and appears to be ignored by MS Project
      // so we will ignore it too!
      if (fromDate != null && toDate != null)
      {
         ProjectCalendarException bce = bc.addCalendarException(fromDate, toDate);
         bce.setName(exception.getName());
         readRecurringData(bce, exception);
         Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes times = exception.getWorkingTimes();
         if (times != null)
         {
            List<Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime> time = times.getWorkingTime();
            for (Project.Calendars.Calendar.Exceptions.Exception.WorkingTimes.WorkingTime period : time)
            {
               Date startTime = period.getFromTime();
               Date endTime = period.getToTime();

               if (startTime != null && endTime != null)
               {
                  if (startTime.getTime() >= endTime.getTime())
                  {
                     endTime = DateHelper.addDays(endTime, 1);
                  }

                  bce.addRange(new DateRange(startTime, endTime));
               }
            }
         }
      }
   }
170944
public function addText(Project $project, $element, $text)
    {
        if ($this->methodAddText === null) {
            $msg = $this->getElementName($project, $element) . " doesn't support nested text data.";
            throw new BuildException($msg);
        }
        try {
            $method = $this->methodAddText;
            $method->invoke($element, $text);
        } catch (Exception $exc) {
            throw new BuildException($exc->getMessage(), $exc);
        }
    }
836486
public function evaluateExclusions($date = null)
    {
        if (!$date) {
            $date = clone $this->now;
        }
        // Check dates of exclusion (if there are any).
        $jsonHelper       = new JSONHelper();
        $exclusionsString = $this->contactClient->getScheduleExclusions();
        $exclusions       = $jsonHelper->decodeArray($exclusionsString, 'ScheduleExclusions');
        if ($exclusions) {
            // Fastest way to compare dates is by string.
            $todaysDateString = $date->format('Y-m-d');
            foreach ($exclusions as $exclusion) {
                if (!empty($exclusion->value)) {
                    $dateString   = trim(str_ireplace('yyyy-', '', $exclusion->value));
                    $segments     = explode('-', $dateString);
                    $segmentCount = count($segments);
                    if (3 == $segmentCount) {
                        $year  = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            4,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format(
                            'Y'
                        );
                        $month = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[2]) ? str_pad(
                            $segments[2],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } elseif (2 == $segmentCount) {
                        $year  = $date->format('Y');
                        $month = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } else {
                        continue;
                    }
                    $dateString = $year.'-'.$month.'-'.$day;
                    if ($dateString == $todaysDateString) {
                        throw new ContactClientException(
                            'This contact client does not allow contacts on the date '.$dateString.'.',
                            0,
                            null,
                            Stat::TYPE_SCHEDULE,
                            false
                        );
                    }
                }
            }
        }

        return $this;
    }
1278077
private function collectBranch(array $start, array $end, array $locations, array $coverage = []) : void
    {
        $this->fileCoverage['branchMap'][] = [
            'type' => 'switch',
            'locations' => $locations,
            'loc' => ['start' => $start, 'end' => $end],
        ];

        $this->fileCoverage['b'][] = $coverage;

        // Collect statements as well (entire branch is a statement, each location is a statement)
        $this->collectStatement($start, $end, (int) array_sum($coverage));

        for ($i = 0, $count = count($locations); $i < $count; ++$i) {
            $this->collectStatement($locations[$i]['start'], $locations[$i]['end'], $coverage[$i]);
        }
    }
1073902
private void readCalendars(Project project) throws MPXJException
   {
      Calendars calendars = project.getCalendars();
      if (calendars != null)
      {
         for (net.sf.mpxj.planner.schema.Calendar cal : calendars.getCalendar())
         {
            readCalendar(cal, null);
         }

         Integer defaultCalendarID = getInteger(project.getCalendar());
         m_defaultCalendar = m_projectFile.getCalendarByUniqueID(defaultCalendarID);
         if (m_defaultCalendar != null)
         {
            m_projectFile.getProjectProperties().setDefaultCalendarName(m_defaultCalendar.getName());
         }
      }
   }
653629
public function deleteFile(string $path, string $message, string $sha,
                               string $branch = AbstractApi::BRANCH_MASTER): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/contents/:path',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $path), Request::METHOD_DELETE, [
                'message' => $message,
                'sha'     => $sha,
                'branch'  => $branch
            ]);
    }
760447
public static function pf_date_indexed($from, $to, $step = '+1 day', $outputFormat = 'Y-m-d') {
        $dates = array();
        $current = strtotime($from);
        $last = strtotime($to);
        while($current <= $last) {
            $dates[] = date($outputFormat, $current);
            $current = strtotime($step, $current);
        }
        return $dates;
    }
1245831
public function seeDateIsInDays($date, $days) {
        \PHPUnit_Framework_Assert::assertEquals($days, $this->_GetNow()->diffInDays($this->_ParseDate($date), false));
    }
609409
public static function validateBranch($branch, VersionParser $parser = null)
    {
        if (null === $parser) {
            $parser = new VersionParser();
        }

        $normalize = $parser->normalizeBranch($branch);

        if (false !== strpos($normalize, '.9999999-dev')) {
            return false;
        }

        return $normalize;
    }
389050
public static function calculateBusinessDaysBetweenTwoDates($startDate, $endDate, $holidays = [])
    {
        // Do strtotime calculations just once
        $endDate = strtotime($endDate);
        $startDate = strtotime($startDate);

        // The total number of days between the two dates. We compute the amount of seconds and divide it to 60*60*24
        // We add one ыусщтв to include both dates in the interval
        $days = ($endDate - $startDate) / 86400 + 1;

        $no_full_weeks = floor($days / 7);
        $no_remaining_days = fmod($days, 7);

        //It will return 1 if it's Monday,.. ,7 for Sunday
        $the_first_day_of_week = date("N", $startDate);
        $the_last_day_of_week = date("N", $endDate);

        // The two can be equal in leap years when february has 29 days, the equal sign is added here
        // In the first case the whole interval is within a week, in the second case the interval falls in two weeks.
        if ($the_first_day_of_week <= $the_last_day_of_week) {
            if ($the_first_day_of_week <= 6 && 6 <= $the_last_day_of_week) {
                $no_remaining_days--;
            }
            if ($the_first_day_of_week <= 7 && 7 <= $the_last_day_of_week) {
                $no_remaining_days--;
            }
        } else {
            // Fix an edge case where the start day was a Sunday and the end day was NOT a Saturday)

            // The day of the week for start is later than the day of the week for end
            if ($the_first_day_of_week == 7) {
                // if the start date is a Sunday, then we definitely subtract 1 day
                $no_remaining_days--;

                if ($the_last_day_of_week == 6) {
                    // if the end date is a Saturday, then we subtract another day
                    $no_remaining_days--;
                }
            } else {
                // the start date was a Saturday (or earlier), and the end date was (Mon..Fri)
                // so we skip an entire weekend and subtract 2 days
                $no_remaining_days -= 2;
            }
        }

        //The amount of business days is: (number of weeks between the two dates) * (5 working days) + the remainder
        // February in none leap years gave a remainder of 0 but still calculated weekends between first and last day, this is one way to fix it
        $workingDays = $no_full_weeks * 5;
        if ($no_remaining_days > 0) {
            $workingDays += $no_remaining_days;
        }

        //We subtract the holidays
        foreach ($holidays as $holiday) {
            $time_stamp = strtotime($holiday);
            // If the holiday doesn't fall in weekend
            if ($startDate <= $time_stamp && $time_stamp <= $endDate && date("N", $time_stamp) != 6 && date("N", $time_stamp) != 7) {
                $workingDays--;
            }
        }

        return $workingDays;
    }
213530
protected function generateInfoYamlMetadata($version, $project, $datestamp)
    {
        $core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
        $date = date('Y-m-d', $datestamp);
        $info = <<<METADATA

# Information add by drustack/composer-generate-metadata on {$date}
core: "{$core}"
project: "{$project}"
version: "{$version}"
datestamp: "{$datestamp}"
METADATA;

        return $info;
    }
825912
public static function get_between_versions($package = 'project', \Datetime $start_date = null, \Datetime $end_date = null) {
		$migrations = self::get_by_package($package);

		foreach ($migrations as $key => $migration) {
			if ($start_date !== null) {
				if ($migration->get_version() <= $start_date) {
					unset($migrations[$key]);
					continue;
				}
			}

			if ($end_date !== null) {
				if ($migration->get_version() >= $end_date) {
					unset($migrations[$key]);
					continue;
				}
			}
		}
		return $migrations;
	}
177221
public function import($repository, $branch = null, $file = null)
    {
        return $this->request(sprintf('github/%s?branch=%s&file=%s', $this->transform($repository), $branch, $file), 'POST');
    }