Skip to content

Commit

Permalink
Added calendar cfield
Browse files Browse the repository at this point in the history
  • Loading branch information
vldiark committed Jan 20, 2020
1 parent 04a806a commit bc11aef
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
53 changes: 53 additions & 0 deletions src/Base/Models/CustomField/CalendarField.php
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);
}
}
3 changes: 2 additions & 1 deletion src/Collections/CustomFieldCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class CustomFieldCollection extends CollectionWrapper
14 => 'Ufee\Amo\Base\Models\CustomField\BirthDayField',
15 => 'Ufee\Amo\Base\Models\CustomField\JurField',
17 => 'Ufee\Amo\Base\Models\CustomField\OrgField',
18 => 'Ufee\Amo\Base\Models\CustomField\CategoryField'
18 => 'Ufee\Amo\Base\Models\CustomField\CategoryField',
19 => 'Ufee\Amo\Base\Models\CustomField\CalendarField'
];

/**
Expand Down

0 comments on commit bc11aef

Please sign in to comment.