ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilDclDatetimeRecordFieldModel.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
26  public function parseValue($value): string
27  {
28  return (string) $value;
29  }
30 
31  public function getValueFromExcel(ilExcel $excel, int $row, int $col): ?string
32  {
33  $value = parent::getValueFromExcel($excel, $row, $col);
34 
35  if ($value) {
36  return date(ilDclDatetimeFieldModel::FORMAT, strtotime($value));
37  } else {
38  return "";
39  }
40  }
41 
46  public function setValueFromForm(ilPropertyFormGUI $form): void
47  {
48  parent::setValueFromForm($form);
49  $date = new ilDateTime(strtotime($this->getValue()), IL_CAL_UNIX);
50  $this->setValue($date->get(IL_CAL_FKT_DATE, ilDclDatetimeFieldModel::FORMAT, $this->user->getTimeZone()));
51  }
52 
56  public function parseSortingValue($value, bool $link = true): ?int
57  {
58  return strtotime($value);
59  }
60 
61  public function getFormulaValue(): string
62  {
63  return (string) strtotime($this->getValue() ?: '');
64  }
65 }
setValue($value, bool $omit_parsing=false)
Set value for record field.
getValueFromExcel(ilExcel $excel, int $row, int $col)
const IL_CAL_UNIX
const IL_CAL_FKT_DATE
setValueFromForm(ilPropertyFormGUI $form)
This value should be UTC but the current ilDateTimeInputGUI enforces the users timezone on an input...