| Conditions | 2 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | public static function localDate2OLE($date = null) |
||
| 32 | { |
||
| 33 | if (!isset($date)) { |
||
| 34 | return str_repeat("\x00", 8); |
||
| 35 | } |
||
| 36 | |||
| 37 | // days from 1-1-1601 until the beggining of UNIX era |
||
| 38 | $days = 134774; |
||
| 39 | // calculate seconds |
||
| 40 | $bigDate = $days * 24 * 3600 + |
||
| 41 | gmmktime( |
||
| 42 | date("H", $date), |
||
| 43 | date("i", $date), |
||
| 44 | date("s", $date), |
||
| 45 | date("m", $date), |
||
| 46 | date("d", $date), |
||
| 47 | date("Y", $date) |
||
| 48 | ); |
||
| 49 | $bigDate *= 10000000; |
||
| 50 | |||
| 51 | // factor used for separating numbers into 4 bytes parts |
||
| 52 | $factor = pow(2, 32); |
||
| 53 | |||
| 54 | $div = $bigDate / $factor; |
||
| 55 | $highPart = floor($div); |
||
| 56 | // lower 4 bytes |
||
| 57 | $lowPart = floor(($div - $highPart) * $factor); |
||
| 58 | |||
| 59 | return pack('V2', $lowPart, $highPart); |
||
| 60 | } |
||
| 61 | } |
||
| 62 |