Fakoli Framework
DateTimeTypeRenderer Class Reference
+ Inheritance diagram for DateTimeTypeRenderer:
+ Collaboration diagram for DateTimeTypeRenderer:

Public Member Functions

 DateTimeTypeRenderer ()
 
- Public Member Functions inherited from AbstractTypeRenderer
 AbstractTypeRenderer ()
 

Static Public Member Functions

static format ($datetime, $template="")
 
- Static Public Member Functions inherited from AbstractTypeRenderer
static format ($value, $template="")
 
static translationDateTemplate ($template, $includeTime=true)
 

Detailed Description

Definition at line 37 of file datetime_type_renderer.inc.

Member Function Documentation

◆ DateTimeTypeRenderer()

DateTimeTypeRenderer::DateTimeTypeRenderer ( )

Definition at line 40 of file datetime_type_renderer.inc.

41  {
42  }

◆ format()

static DateTimeTypeRenderer::format (   $datetime,
  $template = "" 
)
static

Definition at line 63 of file datetime_type_renderer.inc.

64  {
65  trace("DateTimeTypeRenderer template is $template and value is $datetime", 5);
66 
67  $text = "";
68 
69  if($datetime && !$template)
70  $template = "m/d/Y g:ia";
71 
72  // Convert shorthand to format needed for date function
73  $template = AbstractTypeRenderer::translationDateTemplate($template);
74 
75  // strip time component if hours is empty
76  if(preg_match("/00:00:00/", $datetime))
77  {
78  $patterns = "/(g|i|a|:|h|s|b|p|t|z|c|r|u)/i";
79  $template = preg_replace($patterns, "", $template);
80  trace("DateTimeTypeRenderer no time component: template is $template and value is $datetime", 5);
81  }
82 
83  trace("DateTimeTypeRenderer template is $template and value is $datetime", 5);
84 
85  if($datetime)
86  {
87  $dateObj = new DateTime($datetime);
88  $text = $dateObj->format($template);
89  }
90  // else if no date return "";
91 
92  return $text;
93  }
static translationDateTemplate($template, $includeTime=true)
trace($msg, $lvl, $callStack=null)
Send output to the trace log.
Definition: functions.inc:959

The documentation for this class was generated from the following file: