/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to classes/time/fusion.php

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class FUSION {
 
4
    var $reader;
 
5
 
 
6
    var $start_time;
 
7
    var $rate;
 
8
    
 
9
    function __construct(&$reader, $opts = false) {
 
10
        $this->start_time = strtotime("January 16 2008") ;
 
11
//      $this->rate = 10000;
 
12
        $this->rate = 10;
 
13
        $this->reader = &$reader;
 
14
    }
 
15
    
 
16
    function ImportTime($dt) {
 
17
//      $ret = round(dsMathPreciseSubstract($dt->format("U.u"), $this->start_time)*$this->rate);
 
18
//      echo $dt->format("U.u") . "," . $ret . "," . $this->ExportTime($ret)->format("U.u") . ".\n";
 
19
        
 
20
        return round(dsMathPreciseSubstract($dt->format("U.u"), $this->start_time)*$this->rate);
 
21
    }
 
22
    
 
23
    function ExportTime($db_time) {
 
24
        $unix_time = dsMathPreciseAdd($this->start_time, $db_time/$this->rate);
 
25
        $itime = (int)floor($unix_time);
 
26
        
 
27
        if ($itime==$unix_time) {
 
28
            return new DateTime("@$itime", $this->reader->gmt_timezone);
 
29
        } else {
 
30
            $subsec = strchr(sprintf("%F", $unix_time), '.');
 
31
            return new DateTime(strftime("%Y/%m/%d %H:%M:%S", $itime) . $subsec, $this->reader->gmt_timezone);
 
32
        }
 
33
    }
 
34
}
 
35
 
 
36
?>
 
 
b'\\ No newline at end of file'