X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=SimpleExcel.php;h=6515710c392420ebbe241cb58dc0134621642591;hb=e6eb2122a2c49c78628944680de6b01f7439bed7;hp=65f126fee47888df9d068bea4d2ea49477ffe6a7;hpb=e6e839867ad26eb9fdf0e74ec19b4b8266a6b9ad;p=Pman.Core diff --git a/SimpleExcel.php b/SimpleExcel.php index 65f126fe..6515710c 100644 --- a/SimpleExcel.php +++ b/SimpleExcel.php @@ -75,7 +75,8 @@ class Pman_Core_SimpleExcel extends Pman var $workbook = false; var $worksheet= false; - function Pman_Core_SimpleExcel($data,$cfg) + + function __construct($data,$cfg) { // print_r($cfg);exit; require_once 'Spreadsheet/Excel/Writer.php'; @@ -92,11 +93,14 @@ class Pman_Core_SimpleExcel extends Pman $cfg['formats'] = isset($cfg['formats']) ? $cfg['formats'] : array(); + $this->formats['_default_date_format_'] = $workbook->addFormat();; + $this->formats['_default_date_format_']->setNumFormat('YYYY-MM-DD'); + foreach($cfg['formats'] as $f=>$fcfg) { $this->formats[$f] = & $workbook->addFormat(); foreach((array)$fcfg as $k=>$v) { - $this->formats[$f]->{'set' . $k}($v); + $this->formats[$f]->{'set' . $k}($v); } } @@ -380,11 +384,14 @@ class Pman_Core_SimpleExcel extends Pman if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $v)) { $dataFormat = 'date'; - $format = empty($format) ? 'YYYY-MM-DD' : $format; + $format = empty($format) ? $this->formats['_default_date_format_']: $format; $ut_to_ed_diff = 86400 * 25569; + $gmt = strtotime('1970-01-01'); - $v = (strtotime($v) + $ut_to_ed_diff) / 86400; - var_Dump(array($format, $v)); + $v = (strtotime($v) + $ut_to_ed_diff - $gmt) / 86400; + // need to +8hrs to get real time.. + + } if ( (is_numeric($v) && strlen($v) > 1 && substr($v,0,1) == '0' && substr($v,1,1) != '.' )