Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add where date function #891

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/XeroPHP/Remote/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace XeroPHP\Remote;

use DateTime;
use DateTimeInterface;
use XeroPHP\Application;

class Query
Expand Down Expand Up @@ -211,6 +212,17 @@ public function date(DateTime $date)
return $this;
}

/**
* @param DateTimeInterface $date
* @param string $operator the date comparison operator, e.g. >, >=, etc
* @param string $parameter
* @return $this
*/
public function whereDate(DateTimeInterface $date, $operator = '==', $parameter = 'Date')
{
return $this->addWhere('AND', [sprintf("$parameter $operator DateTime(%s)", $date->format('Y, m, d'))]);
}

/**
* @param int $page
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests\Application;
namespace XeroPHP\Tests\Application;

use XeroPHP\Application;

Expand Down