Path: blob/master/src/infrastructure/export/field/PhabricatorEpochExportField.php
12241 views
<?php12final class PhabricatorEpochExportField3extends PhabricatorExportField {45private $zone;67public function getTextValue($value) {8if ($value === null) {9return '';10}1112if (!isset($this->zone)) {13$this->zone = new DateTimeZone('UTC');14}1516try {17$date = new DateTime('@'.$value);18} catch (Exception $ex) {19return null;20}2122$date->setTimezone($this->zone);23return $date->format('c');24}2526public function getNaturalValue($value) {27if ($value === null) {28return $value;29}3031return (int)$value;32}3334public function getPHPExcelValue($value) {35$epoch = $this->getNaturalValue($value);3637if ($epoch === null) {38return null;39}4041$seconds_per_day = phutil_units('1 day in seconds');42$offset = ($seconds_per_day * 25569);4344return ($epoch + $offset) / $seconds_per_day;45}4647/**48* @phutil-external-symbol class PHPExcel_Style_NumberFormat49*/50public function formatPHPExcelCell($cell, $style) {51$code = PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2;5253$style54->getNumberFormat()55->setFormatCode($code);56}5758}596061