Implemented a basic date view helper
authorChristopher Hlubek <hlubek@networkteam.com>
Fri, 27 Mar 2009 15:14:41 +0000 (15:14 +0000)
committerChristopher Hlubek <hlubek@networkteam.com>
Fri, 27 Mar 2009 15:14:41 +0000 (15:14 +0000)
typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php [new file with mode: 0644]

diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php
new file mode 100644 (file)
index 0000000..dce85af
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+/*                                                                        *
+ * This script is part of the TYPO3 project - inspiring people to share!  *
+ *                                                                        *
+ * TYPO3 is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License version 2 as published by  *
+ * the Free Software Foundation.                                          *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
+ * Public License for more details.                                       *
+ *                                                                        */
+
+/**
+ * A simple date format view helper.
+ *
+ * @package
+ * @subpackage
+ * @version $Id:$
+ */
+class Tx_Fluid_ViewHelpers_Format_DateViewHelper extends Tx_Fluid_Core_AbstractViewHelper {
+       /**
+        * Render the supplied DateTime object as a formatted date.
+        *
+        * @param string $format The date format in date() syntax
+        * @param DateTime $value The DateTime object to format
+        * @return string Formatted date
+        * @author Christopher Hlubek <hlubek@networkteam.com>
+        */
+       public function render($value, $format = 'Y-m-d H:i') {
+               $formattedDate = '';
+               if ($value != NULL) {
+                       $formattedDate = $value->format($format);
+               }
+               return $formattedDate;
+       }
+}
+
+
+?>
\ No newline at end of file