Skip to content

Commit 2770781

Browse files
committed
Fixed since() query returning empty response #215
1 parent b1424c4 commit 2770781

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Detailed [config/imap.php](src/config/imap.php) configuration:
121121
- `validate_cert` — decide weather you want to verify the certificate or not
122122
- `username` — imap account username
123123
- `password` — imap account password
124+
- `date_format` — The default date format is used to convert any given Carbon::class object into a valid date string. (`d-M-Y`, `d-M-y`, `d M y`)
124125
- `options` — additional fetch options
125126
- `delimiter` — you can use any supported char such as ".", "/", etc
126127
- `fetch` — `IMAP::FT_UID` (message marked as read by fetching the message) or `IMAP::FT_PEEK` (fetch the message without setting the "read" flag)

src/IMAP/Query/Query.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class Query {
5757
/** @var int $fetch_flags */
5858
protected $fetch_flags = true;
5959

60+
/** @var string $date_format */
61+
protected $date_format;
62+
6063
/**
6164
* Query constructor.
6265
* @param Client $client
@@ -67,6 +70,8 @@ public function __construct(Client $client, $charset = 'UTF-8') {
6770

6871
if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
6972

73+
$this->date_format = config('imap.date_format', 'd M y');
74+
7075
$this->charset = $charset;
7176
$this->query = collect();
7277
$this->boot();
@@ -86,7 +91,7 @@ protected function boot(){}
8691
protected function parse_value($value){
8792
switch(true){
8893
case $value instanceof \Carbon\Carbon:
89-
$value = $value->format('d M y');
94+
$value = $value->format($this->date_format);
9095
break;
9196
}
9297

src/config/imap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
*/
2525
'default' => env('IMAP_DEFAULT_ACCOUNT', 'default'),
2626

27+
/*
28+
|--------------------------------------------------------------------------
29+
| Default date format
30+
|--------------------------------------------------------------------------
31+
|
32+
| The default date format is used to convert any given Carbon::class object into a valid date string.
33+
| These are currently known working formats: "d-M-Y", "d-M-y", "d M y"
34+
|
35+
*/
36+
'date_format' => 'd-M-Y',
37+
2738
/*
2839
|--------------------------------------------------------------------------
2940
| Available IMAP accounts

0 commit comments

Comments
 (0)