author | Dan |
Sun, 23 Mar 2008 23:11:56 -0400 | |
changeset 6 | 5f35ebc4f9bb |
parent 0 | c63de9eb7045 |
permissions | -rw-r--r-- |
0
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
1 |
<?php |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
2 |
/** |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
3 |
* Smarty shared plugin |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
4 |
* @package Smarty |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
5 |
* @subpackage plugins |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
6 |
*/ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
7 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
8 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
9 |
/** |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
10 |
* Function: smarty_make_timestamp<br> |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
11 |
* Purpose: used by other smarty functions to make a timestamp |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
12 |
* from a string. |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
13 |
* @author Monte Ohrt <monte at ohrt dot com> |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
14 |
* @param string |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
15 |
* @return string |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
16 |
*/ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
17 |
function smarty_make_timestamp($string) |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
18 |
{ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
19 |
if(empty($string)) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
20 |
// use "now": |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
21 |
$time = time(); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
22 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
23 |
} elseif (preg_match('/^\d{14}$/', $string)) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
24 |
// it is mysql timestamp format of YYYYMMDDHHMMSS? |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
25 |
$time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
26 |
substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
27 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
28 |
} elseif (is_numeric($string)) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
29 |
// it is a numeric string, we handle it as timestamp |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
30 |
$time = (int)$string; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
31 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
32 |
} else { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
33 |
// strtotime should handle it |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
34 |
$time = strtotime($string); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
35 |
if ($time == -1 || $time === false) { |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
36 |
// strtotime() was not able to parse $string, use "now": |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
37 |
$time = time(); |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
38 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
39 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
40 |
return $time; |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
41 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
42 |
} |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
43 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
44 |
/* vim: set expandtab: */ |
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
45 |
|
c63de9eb7045
First commit. Basic things are working and implemented (webserver, templating, DCOP interface)
Dan
parents:
diff
changeset
|
46 |
?> |