diff --git a/control/Controller.php b/control/Controller.php index df424c000..b654b7f97 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -406,15 +406,6 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { //----------------------------------------------------------------------------------- /** - * returns a date object for use within a template - * Usage: $Now.Year - Returns 2006 - * @return Date The current date - */ - function Now() { - $d = new Date(null); - $d->setValue(date("Y-m-d h:i:s")); - return $d; - } * Pushes this controller onto the stack of current controllers. * This means that any redirection, session setting, or other things that rely on Controller::curr() will now write to this * controller object. diff --git a/model/fieldtypes/Datetime.php b/model/fieldtypes/Datetime.php index ac4536877..ee6a30b13 100644 --- a/model/fieldtypes/Datetime.php +++ b/model/fieldtypes/Datetime.php @@ -23,7 +23,7 @@ * @package sapphire * @subpackage model */ -class SS_Datetime extends Date { +class SS_Datetime extends Date implements TemplateGlobalProvider { function setValue($value) { if($value === false || $value === null || (is_string($value) && !strlen($value))) { @@ -124,5 +124,11 @@ class SS_Datetime extends Date { static function clear_mock_now() { self::$mock_now = null; } + + public static function get_template_global_variables() { + return array( + 'Now' => array('method' => 'now', 'casting' => 'SS_Datetime'), + ); + } }