/**
  * Get the trial end timestamp for a Conekta subscription update.
  *
  * @return int
  */
 protected function getTrialEndForUpdate()
 {
     if ($this->skipTrial) {
         return Carbon::now()->toIso8601String();
     }
     return $this->trialEnd ? $this->trialEnd->toIso8601String() : null;
 }
Example #2
0
 /**
  * __invoke
  *
  * Summaries for methods should use 3rd person declarative rather
  * than 2nd person imperative, beginning with a verb phrase.
  *
  * @param mixed $date   DESCRIPTION
  * @param mixed $attr   DESCRIPTION
  * @param mixed $format DESCRIPTION
  *
  * @return mixed
  *
  * @access public
  */
 public function __invoke($date, $attr = [], $format = null)
 {
     $date = new Carbon($date);
     $attr = array_merge_recursive($attr, ['datetime' => $date->toIso8601String()]);
     $content = $format ? $date->format($format) : $date->toDayDateTimeString();
     return parent::__invoke($content, $attr, $this->tag);
 }
Example #3
0
 private function validateTimestamp($timestamp)
 {
     if ($timestamp instanceof Carbon) {
         $carbon = $timestamp;
     } else {
         if ($timestamp instanceof DateTime) {
             $carbon = Carbon::instance($timestamp);
         } else {
             if (is_string($timestamp) && strtotime($timestamp) !== false) {
                 $carbon = new Carbon($timestamp);
             } else {
                 throw new \InvalidArgumentException('Invalid date/time format.');
             }
         }
     }
     $this->timestamp = $carbon->toIso8601String();
 }
Example #4
0
 public function getCreatedAtAttribute($value)
 {
     $dt = new Carbon($value);
     return $dt->toIso8601String();
 }
 /**
  * タスクにリマインダーを設定する
  *
  * @param array $task 1タスクを表す配列
  * @param Carbon $date リマインダー設定日時
  */
 private function createReminder($task, Carbon $date)
 {
     $newReminder['task_id'] = $task['id'];
     $newReminder['date'] = $date->toIso8601String();
     $url = 'a.wunderlist.com/api/v1/reminders';
     $this->poster->post($url, $newReminder, $this->tokens);
 }
Example #6
0
 public function getTimestampAttribute()
 {
     $date = new Carbon($this->attributes['timestamp'], 'Asia/Bangkok');
     return $date->toIso8601String();
 }
 /**
  * Cast an attribute from a PHP type.
  *
  * @param $castTypes
  * @param $key
  * @param $value
  * @return mixed
  * @internal param BaseModel $model
  * @internal param $object
  */
 private function castAttribute($castTypes, $key, $value)
 {
     if (!array_key_exists($key, $castTypes)) {
         return $value;
     }
     $castType = $castTypes[$key];
     if ($value && in_array($castType, ['date', 'datetime'])) {
         $date = new Carbon($value);
         switch ($castType) {
             case 'date':
                 return $date->format('Y-m-d');
             default:
                 return $date->toIso8601String();
         }
     }
     return $value;
 }