<?php
 namespace Engine\RemoteData\InfoBox; class Field_DateInterval extends FieldAbstract { const DIFF_NONE = null; const DIFF_DAYS = 'days'; const DIFF_NIGHTS = 'nights'; const DIFF_HOURS = 'hours'; const DIFF_NIGHTS_OR_HOURS = 'nights_or_hours'; public function setValue($value) { if ( !($value['start'] instanceof \Engine\DateTime) ) { throw new Exception(sprintf('%s start field must receive an \Engine\DateTime object', __CLASS__)); } if ( !($value['end'] instanceof \Engine\DateTime) ) { throw new Exception(sprintf('%s end field must receive an \Engine\DateTime object', __CLASS__)); } return parent::setValue($value); } public function exportAsArray() { $ret = parent::exportAsArray(); $ret['showDifference'] = $this->value['showDifference']; return $ret; } public function exportAsStdObj() { $ret = parent::exportAsStdObj(); $ret->showDifference = $this->value['showDifference']; return $ret; } public function exportValue() { return [ 'start' => ($this->value['start']->formatDateTimeIso()?:""), 'end' => ($this->value['end']->formatDateTimeIso()?:""), ]; } }