* (bug 4582) Provide preference-based autoformatting of unlinked dates with the datef...
[lhc/web/wiklou.git] / includes / parser / CoreParserFunctions.php
index 9c90d1b..8371451 100644 (file)
@@ -67,6 +67,7 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'subjectpagename',  array( __CLASS__, 'subjectpagename'  ), SFH_NO_HASH );
                $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH );
                $parser->setFunctionHook( 'tag',              array( __CLASS__, 'tagObj'           ), SFH_OBJECT_ARGS );
+               $parser->setFunctionHook( 'formatdate',           array( __CLASS__, 'formatDate'           ), SFH_NO_HASH );
 
                if ( $wgAllowDisplayTitle ) {
                        $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
@@ -87,6 +88,14 @@ class CoreParserFunctions {
                        return array( 'found' => false );
                }
        }
+       
+       static function formatDate( $parser, $date ) {
+               $df = DateFormatter::getInstance();
+               
+               $pref = $parser->mOptions->getDateFormat();
+               $date = $df->reformat( $pref, $date, false );
+               return $date;
+       }
 
        static function ns( $parser, $part1 = '' ) {
                global $wgContLang;