Index: /home/metskem/workspace/JSPWiki/etc/i18n/CoreResources.properties
===================================================================
--- /home/metskem/workspace/JSPWiki/etc/i18n/CoreResources.properties	(revision 734476)
+++ /home/metskem/workspace/JSPWiki/etc/i18n/CoreResources.properties	(working copy)
@@ -206,8 +206,8 @@
 varmgr.authenticated=authenticated
 varmgr.asserted=asserted
 varmgr.anonymous=anonymous
-varmgr.dateformat.invalid=No valid dateformat was provided: 
-varmgr.dateformat.noformat=No dateformat was provided. 
+varmgr.dateformat.invalid.format=No valid dateformat was provided: 
+varmgr.dateformat.invalid.parm=Unrecognized parameter: 
 
 ###############################################################################
 ## Default Resource Bundle file for the Stripes Framework. Values should be
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/VariableManager.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/VariableManager.java	(revision 734476)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/VariableManager.java	(working copy)
@@ -36,6 +36,8 @@
 import com.ecyrd.jspwiki.filters.PageFilter;
 import com.ecyrd.jspwiki.i18n.InternationalizationManager;
 import com.ecyrd.jspwiki.modules.InternalModule;
+import com.ecyrd.jspwiki.preferences.Preferences;
+import com.ecyrd.jspwiki.preferences.Preferences.TimeFormat;
 
 /**
  *  Manages variables.  Variables are case-insensitive.  A list of all
@@ -336,32 +338,42 @@
             }
 
             //
-            // handle the timestamp variable ( example: timestamp=yyyy-MM-dd)
+            // handle the timestamp variable ( example: $timestamp format=yyyy-MM-dd)
             //
 
-            if( varName.startsWith( "timeStamp" ) )
+            if( varName.toLowerCase().startsWith( "timestamp" ) )
             {
-                StringTokenizer tok = new StringTokenizer( varName, "=" );
+                StringTokenizer tok= new StringTokenizer( varName, " " );
                 int numTokens = tok.countTokens();
-                if( numTokens != 2 )
+                if( numTokens == 1 )
                 {
-                    return context.getBundle( InternationalizationManager.CORE_BUNDLE ).getString( "varmgr.dateformat.noformat" );
+                    // no (format) param was given, return the user default
+                    return Preferences.getDateFormat( context, TimeFormat.DATETIME ).format( new Date() );
                 }
 
-                @SuppressWarnings( "unused" )
-                String ignoreFirstToken = tok.nextToken();
-                String dateFormatString = tok.nextToken();
+                if( numTokens >= 2 )
+                {
+                    @SuppressWarnings( "unused" )
+                    String ignoreFirstToken = tok.nextToken();
+                    String parm1 = tok.nextToken( "=" ).trim();
+                    if( !parm1.startsWith( "format" ) )
+                    {
+                        return context.getBundle( InternationalizationManager.CORE_BUNDLE )
+                            .getString( "varmgr.dateformat.invalid.parm" ) + parm1;
+                    }
 
-                SimpleDateFormat dateFormat = null;
-                try
-                {
-                    dateFormat = new SimpleDateFormat( dateFormatString );
-                    return dateFormat.format( new Date( System.currentTimeMillis() ) );
-                }
-                catch( RuntimeException e )
-                {
-                    return context.getBundle( InternationalizationManager.CORE_BUNDLE ).getString( "varmgr.dateformat.invalid" )
-                           + dateFormatString;
+                    String dateFormatString = tok.nextToken();
+                    SimpleDateFormat dateFormat = null;
+                    try
+                    {
+                        dateFormat = new SimpleDateFormat( dateFormatString );
+                        return dateFormat.format( new Date( ) );
+                    }
+                    catch( RuntimeException e )
+                    {
+                        return context.getBundle( InternationalizationManager.CORE_BUNDLE ).getString( "varmgr.dateformat.invalid.format" )
+                               + dateFormatString;
+                    }
                 }
             }
             
Index: /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/VariableManagerTest.java
===================================================================
--- /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/VariableManagerTest.java	(revision 734476)
+++ /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/VariableManagerTest.java	(working copy)
@@ -31,6 +31,8 @@
 import junit.framework.TestSuite;
 
 import com.ecyrd.jspwiki.content.WikiName;
+import com.ecyrd.jspwiki.preferences.Preferences;
+import com.ecyrd.jspwiki.preferences.Preferences.TimeFormat;
 
 public class VariableManagerTest extends TestCase
 {
@@ -192,21 +194,42 @@
         assertEquals( "Testing {}, {{{}", res );
     }
 
-    public void testTimeStamp() throws Exception
+    public void testTimeStamp1() throws Exception
     {
         // Yes I know there is a tiny chance that this fails if the minute
-        // passes by between here and the "new Date" in VariableManager
+        // passes by between here and the "new Date()" in VariableManager
+        //
         String format = "dd.MM.yyyy HH:mm";
         SimpleDateFormat df = new SimpleDateFormat( format );
         String dateString = df.format( new Date() );
+        String res = m_variableManager.expandVariables( m_context, ">>>>>{$timestamp format=" + format + "}<<<<<" );
+        assertEquals( ">>>>>" + dateString + "<<<<<", res );
+    }
 
-        String res = m_variableManager.expandVariables( m_context, ">>>>>{$timeStamp=" + format + "}<<<<<" );
-        assertEquals( ">>>>>" + dateString + "<<<<<", res );
+    public void testTimeStamp2() throws Exception
+    {
+        // test for default dateformat
+        //
+        String defaultDateFormat = Preferences.getDateFormat( m_context, TimeFormat.DATETIME ).format( new Date() );
+
+        String res = m_variableManager.expandVariables( m_context, ">>>>>{$timestamp}<<<<<" );
+        assertEquals( ">>>>>" + defaultDateFormat + "<<<<<", res );
+    }
 
-        res = m_variableManager.expandVariables( m_context, ">>>>>{$timeStamp}<<<<<" );
-        assertEquals( ">>>>>No dateformat was provided. <<<<<", res );
+    public void testTimeStamp3() throws Exception
+    {
+        // test with a wrong named parm
+        //
+        String res = m_variableManager.expandVariables( m_context, ">>>>>{$timestamp wrongparm=bla}<<<<<" );
+        assertEquals( ">>>>>Unrecognized parameter: wrongparm<<<<<", res );
+    }
 
-        res = m_variableManager.expandVariables( m_context, ">>>>>{$timeStamp=" + format + "INVALIDFORMAT}<<<<<" );
+    public void testTimeStamp4() throws Exception
+    {
+        // tests with an invalid date format
+        //
+        String format = "dd.MM.yyyy HH:mm";
+        String res = m_variableManager.expandVariables( m_context, ">>>>>{$timestamp format=" + format + "INVALIDFORMAT}<<<<<" );
         assertEquals( ">>>>>No valid dateformat was provided: dd.MM.yyyy HH:mmINVALIDFORMAT<<<<<", res );
     }
 

