<?php

class UnixTimestampTranslator implements ITranslator {



	protected $format;



	public function __construct($format) {
		$this->format = $format;
	}



	public function vtom($value) {
		$t = strptime($value, $this->format);
		return ($t === null or $t == -1)
			? null
			: mktime($t['tm_hour'], $t['tm_min'], $t['tm_sec'], 1, $t['tm_yday'] + 1, $t['tm_year'] + 1900);
	}



	public function mtov($value) {
		return is_numeric($value) ? strftime($this->format, $value) : null;
	}



} // class UnixTimestampTranslator

?>