Sets current DateTimeSpan to the difference between two QDateTime objects

@param QDateTime $dttFrom
@param QDateTime $dttTo
337802
public function setFromQDateTime(QDateTime $dttFrom, QDateTime $dttTo)
    {
        $this->add($dttFrom->difference($dttTo));
    }
1134925
public static function toDateTime($value, DateTimeZone $dtz) : DateTime
    {
        // TODO : Figure out where to move. Can vary for different source objects
        $format = 'Y-m-d H:i:s';

        if (is_string($value)) {
            $val = strtotime($value);
            if (false === $val) {
                throw new InvalidArgumentException(sprintf('Unsupported datetime string provided: %s', $value));
            }

            return new DateTime(date($format, $val), $dtz);
        }

        if ($value instanceof Time) {
            $value = $value->format($format);

            return new DateTime($value, $dtz);
        }

        if ($value instanceof DateTime) {
            return $value;
        }

        throw new InvalidArgumentException("Type [" . gettype($value) . "] is not supported for date/time");
    }
407372
public function selectActivitiesForInterval($dateFrom, $dateTo)
	{
		$stmt = $this->pdo->prepare(<<<EOT
SELECT 
	t1.*,
	t2.ProjectId AS "Project.ProjectId",
	t2.Name AS "Project.Name",
	t2.Description AS "Project.Description",
	t2.Created AS "Project.Created"
FROM `$this->tableName` AS t1 
LEFT JOIN Projects AS t2 ON t1.ProjectId = t2.ProjectId 
WHERE t1.Started > :dateFrom AND t1.Started < :dateTo  
ORDER BY t1.Started DESC ;
EOT
		);
		$stmt->bindParam(':dateFrom', $dateFrom, \PDO::PARAM_STR);
		$stmt->bindParam(':dateTo', $dateTo, \PDO::PARAM_STR);
		$res = $stmt->execute();

		if ($res === false) {
			return array();
		}

		$rows = $stmt->fetchAll();

		$ret = array();
		foreach ($rows as $row) {
			array_push($ret, $this->prepareEntity($row));
		}

		return $ret;
	}
63154
private function setDateContext(\DateTime $dateContext = null)
    {
        if (!$dateContext) { // we havent set context so we need the default to be: now minus 15 mins, rounded to 5 min increment.
            $now = new \DateTime();
            $now->sub(new \DateInterval('PT15M'));
            // round down to 5 minute increment
            $now->setTime($now->format('H'), floor($now->format('i') / 5) * 5, 0);
            $dateContext = $now;
        }
        $this->dateContext = $dateContext;
    }
1359131
def cast_datetime(ts, fmt=None):
    """"""
    dt = datetime.datetime.fromtimestamp(ts)
    if fmt:
        return dt.strftime(fmt)
    return dt
1350797
def setCurrentDateTime(self, dtime):
        
        view = self.uiGanttVIEW
        scene = view.scene()
        point = view.mapToScene(0, 0)
        x = scene.datetimeXPos(dtime)
        y = point.y()
        view.ensureVisible(x, y, 1, 1)
1130040
public function setDatetime($dateTime)
    {
        $dt = strtotime($dateTime);
        if ($dt == -1) {
            $this->setError(
                "Date of " . $dateTime
                . " Cannot be parsed correctly. It should be in"
                . " a format parsable by PHP's strtotime() function."
            );
        } else {
            $this->dateTime = $dateTime;
            $this->setSeconds($dt);
        }
    }
175505
protected function isOutOfRange($calendarDate, $minTimestamp, $maxTimestamp)
    {
        $timestamp = strtotime(explode('T', $calendarDate)[0]);

        return $timestamp < $minTimestamp || $timestamp > $maxTimestamp;
    }
949957
public function setSearchDateTimeRange(DateTimeInterface $dateTimeFrom, DateTimeInterface $dateTimeUntil): void
    {
        $this->dateTimeFrom = $dateTimeFrom;
        $this->dateTimeUntil = $dateTimeUntil;
        $this->query = $this->createSearchQuery();
    }
1129753
def dtcurrent(self, value):
        """"""
        assert isinstance(value, bool)
        if value and self.dparamscurrent:
            raise RuntimeError("Can't set both dparamscurrent and dtcurrent True")
        if value != self.dtcurrent:
            self._dtcurrent = value
            self._updateInternals()
1288900
public static function timeDiff($timeA, $timeB)
    {
        $a=strtotime($timeA);
        $b=strtotime($timeB);
        $c=$a-$b;
        $c=$c / 3600;
        return $c;
    }
767561
def mtime(self, fpath=None):
        
        return dtformat(
            datetime.datetime.utcfromtimestamp(
                os.path.getmtime(fpath or self.fpath)))
681358
public static function diffMonths(\DateTime $dateTime1, \DateTime $dateTime2): int
    {
        $diff = $dateTime1->diff($dateTime2);

        return ((int)$diff->format('%y') * 12) + (int)$diff->format('%m');
    }
1004686
public function initDatetimeObject($datetimeOrTimestamp = null, $inputTimezone = null, $outputTimezone = null) {
		if(!$inputTimezone) {
			$inputTimezone = $this->serverTimezone;
		}
		if(!$outputTimezone) {
			$outputTimezone = $this->clientTimezone;
		}

		if(strlen($datetimeOrTimestamp) == 10) {
			$isTimeStamp = is_numeric($datetimeOrTimestamp);
			$isDate = !$isTimeStamp;
		}
		else {
			$isTimeStamp = false;
			$isDate = false;
		}

		if($isTimeStamp) {
			$datetime = new \DateTime();
			$datetime->setTimestamp($datetimeOrTimestamp);
		}
		else {
			$datetime = new \DateTime($datetimeOrTimestamp, $inputTimezone ? $this->getTimezoneObject($inputTimezone) : null);
		}

		if(!$isDate && $outputTimezone && $outputTimezone != $inputTimezone) {
			$datetime->setTimezone($this->getTimezoneObject($outputTimezone));
		}
		return $datetime;
	}
677236
private static String getTimeForApi (Date dt) {
        Calendar calendar = new GregorianCalendar();
        TimeZone timeZone = calendar.getTimeZone();
        Calendar cal = Calendar.getInstance(timeZone);
        cal.setTime(dt);
        return String.format("%tFT%<tRZ", cal);
    }
180860
@Override
    public void appendTimestamp(StringBuffer buffer, Date datetime) {
        SimpleDateFormat formatter = new SimpleDateFormat(SyslogConstants.SYSLOG_DATEFORMAT_RFC5424);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(datetime.getTime());
        String formatedTimestamp = formatter.format(calendar.getTime());
        buffer.append(formatedTimestamp);	
        buffer.append(' ');
    }
241900
public static function diffDays(\DateTime $dateTime1, \DateTime $dateTime2): int
    {
        $diff = $dateTime1->diff($dateTime2);

        return (int)$diff->format('%a');
    }