00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 class GitCommitStamp
00022 {
00023 public $name;
00024 public $email;
00025 public $time;
00026 public $offset;
00027
00028 public function unserialize($data)
00029 {
00030 assert(preg_match('/^(.+?)\s+<(.+?)>\s+(\d+)\s+([+-]\d{4})$/', $data, $m));
00031 $this->name = $m[1];
00032 $this->email = $m[2];
00033 $this->time = intval($m[3]);
00034 $off = intval($m[4]);
00035 $this->offset = ($off/100) * 3600 + ($off%100) * 60;
00036 }
00037
00038 public function serialize()
00039 {
00040 if ($this->offset%60)
00041 throw new Exception('cannot serialize sub-minute timezone offset');
00042 return sprintf('%s <%s> %d %+05d', $this->name, $this->email, $this->time, ($this->offset/3600)*100 + ($this->offset/60)%60);
00043 }
00044 };
00045 ?>