Framework
3.9
time_type_renderer.inc
Go to the documentation of this file.
1
<?php
6
/**************************************************************
7
8
Copyright (c) 2018 Sonjara, Inc
9
10
Permission is hereby granted, free of charge, to any person
11
obtaining a copy of this software and associated documentation
12
files (the "Software"), to deal in the Software without
13
restriction, including without limitation the rights to use,
14
copy, modify, merge, publish, distribute, sublicense, and/or sell
15
copies of the Software, and to permit persons to whom the
16
Software is furnished to do so, subject to the following
17
conditions:
18
19
The above copyright notice and this permission notice shall be
20
included in all copies or substantial portions of the Software.
21
22
Except as contained in this notice, the name(s) of the above
23
copyright holders shall not be used in advertising or otherwise
24
to promote the sale, use or other dealings in this Software
25
without prior written authorization.
26
27
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
29
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
31
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
32
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
34
OTHER DEALINGS IN THE SOFTWARE.
35
36
*****************************************************************/
37
38
require_once realpath(dirname(__FILE__).
"/abstract_type_renderer.inc"
);
39
40
class
TimeTypeRenderer
extends
AbstractTypeRenderer
41
{
42
43
function
__construct
()
44
{
45
}
46
47
static
function
format
($time, $template =
""
)
48
{
49
$text =
""
;
50
51
if
($template ==
"12hr"
)
52
{
53
$template =
"g:ia"
;
54
}
55
else
if
($template ==
"24hr"
)
56
{
57
$template =
"H:i"
;
58
}
59
else
if
(!$template)
60
{
61
$template =
"g:ia"
;
62
}
63
64
$dateObj =
new
DateTime($time);
65
$text = $dateObj->format($template);
66
67
return
$text;
68
}
69
}
70
AbstractTypeRenderer
Definition:
abstract_type_renderer.inc:50
TimeTypeRenderer
Definition:
time_type_renderer.inc:41
TimeTypeRenderer\__construct
__construct()
Definition:
time_type_renderer.inc:43
TimeTypeRenderer\format
static format($time, $template="")
Definition:
time_type_renderer.inc:47
code
cms.sonjara.com
framework
data_type_renderers
time_type_renderer.inc
Generated on Tue Mar 23 2021 16:28:45 for Framework by
1.9.1