1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Kernel\Dtype;
13:
14: use Xoops\Core\Kernel\Dtype;
15: use Xoops\Core\Kernel\XoopsObject;
16:
17: /**
18: * DtypeSimpleTime
19: *
20: * Handles the old types XOBJ_DTYPE_STIME, XOBJ_DTYPE_MTIME and XOBJ_DTYPE_LTIME
21: * Expects as input and integer unix timestamp, or string that can be converted to a unix timestamp
22: * using strtotime()
23: *
24: * @category Xoops\Core\Kernel\Dtype\DtypeSimpleTime
25: * @package Xoops\Core\Kernel
26: * @author trabis <lusopoemas@gmail.com>
27: * @copyright 2011-2015 XOOPS Project (http://xoops.org)
28: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
29: * @link http://xoops.org
30: */
31: class DtypeSimpleTime extends DtypeAbstract
32: {
33: /**
34: * cleanVar prepare variable for persistence
35: *
36: * @param XoopsObject $obj object containing variable
37: * @param string $key name of variable
38: *
39: * @return int
40: */
41: public function cleanVar(XoopsObject $obj, $key)
42: {
43: $value = $obj->vars[$key]['value'];
44: $value = !is_string($value) ? (int)($value) : strtotime($value);
45: return $value;
46: }
47: }
48: