-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vldiark
committed
Jan 20, 2020
1 parent
04a806a
commit bc11aef
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* amoCRM Entity custom field type - 19 | ||
*/ | ||
namespace Ufee\Amo\Base\Models\CustomField; | ||
use Ufee\Amo\Amoapi; | ||
|
||
class CalendarField extends EntityField | ||
{ | ||
/** | ||
* Get formatted date | ||
* @return string | ||
*/ | ||
public function format($format) | ||
{ | ||
if (!$date = $this->getValue()) { | ||
return null; | ||
} | ||
$date = new \DateTime($date, new \DateTimeZone(Amoapi::getInstance($this->account_id)->getAuth('timezone'))); | ||
return $date->format($format); | ||
} | ||
|
||
/** | ||
* Get date timestamp | ||
* @return integer | ||
*/ | ||
public function getTimestamp() | ||
{ | ||
if (!$date = $this->getValue()) { | ||
return null; | ||
} | ||
$date = new \DateTime($date, new \DateTimeZone(Amoapi::getInstance($this->account_id)->getAuth('timezone'))); | ||
return $date->getTimestamp(); | ||
} | ||
|
||
/** | ||
* Set date timestamp | ||
* @param integer $stamp | ||
*/ | ||
public function setTimestamp($stamp) | ||
{ | ||
return $this->setValue(date('Y-m-d H:i:s', $stamp)); | ||
} | ||
|
||
/** | ||
* Set date | ||
* @param string $date | ||
*/ | ||
public function setDate($date) | ||
{ | ||
return $this->setValue($date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters