3
class CSVHandler extends DATAHandler {
8
function __construct(&$opts = NULL, STREAMHandler $h = NULL) {
10
global $CSV_DATE_FORMAT;
12
$this->content_type = "text/csv";
13
$this->extension = "csv";
15
parent::__construct($opts, $h);
18
$this->separator = $opts['separator'];
19
$this->date_format = $opts['date_format'];
22
if (!$this->separator) $this->separator = $CSV_SEPARATOR;
23
if (!$this->date_format) $this->date_format = $CSV_DATE_FORMAT;
26
function TimeHeader($flags = 0) {
27
$this->h->Write("Date/Time");
30
function DataHeader(&$header, $i, $flags = 0) {
31
$this->h->Write($this->separator . " " . preg_replace("/" . $this->separator . "/", " ", $header));
34
function HeaderEnd($flags = 0) {
35
$this->h->Write("\r\n");
38
function VectorEnd($flags = 0) {
39
$this->h->Write("\r\n");
42
function TimeValue(&$time, $flags = 0) {
43
if ($this->subseconds) {
45
if (is_float($unix_time)) $subsec = strchr(sprintf("%F", $unix_time), '.');
46
else $subsec = strchr($unix_time, '.');
48
$subsec = strchr(sprintf("%.6F", $time), '.');
49
$this->h->Write(date($this->date_format, $time) . $subsec);
51
$this->h->Write(date($this->date_format, $time));
54
function DataValue(&$value, $i, $flags = 0) {
55
$this->h->Write($this->separator . " " . $value);
b'\\ No newline at end of file'