Optimize standard_date()
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 9637e26..6686089 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -121,22 +121,20 @@
 	 * @param	int	Unix timestamp
 	 * @return	string
 	 */
-	function standard_date($fmt = 'DATE_RFC822', $time = '')
+	function standard_date($fmt = 'DATE_RFC822', $time = NULL)
 	{
-		$formats = array(
-				'DATE_ATOM'		=>	'%Y-%m-%dT%H:%i:%s%P',
-				'DATE_COOKIE'	=>	'%l, %d-%M-%y %H:%i:%s UTC',
-				'DATE_ISO8601'	=>	'%Y-%m-%dT%H:%i:%s%P',
-				'DATE_RFC822'	=>	'%D, %d %M %y %H:%i:%s %O',
-				'DATE_RFC850'	=>	'%l, %d-%M-%y %H:%i:%s UTC',
-				'DATE_RFC1036'	=>	'%D, %d %M %y %H:%i:%s %O',
-				'DATE_RFC1123'	=>	'%D, %d %M %Y %H:%i:%s %O',
-				'DATE_RFC2822'	=>	'%r',
-				'DATE_RSS'		=>	'%D, %d %M %Y %H:%i:%s %O',
-				'DATE_W3C'		=>	'%Y-%m-%dT%H:%i:%s%P'
-				);
+		if (empty($time))
+		{
+			$time = now();
+		}
 
-		return isset($formats[$fmt]) ? mdate($formats[$fmt], $time) : FALSE;
+		// Procedural style pre-defined constants from the DateTime extension
+		if (strpos($fmt, 'DATE_') !== 0 OR defined($fmt) === FALSE)
+		{
+			return FALSE;
+		}
+
+		return date(constant($fmt), $time);
 	}
 }
 
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index eaf4cf8..1b79b94 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -69,7 +69,7 @@
 	public function test_standard_date_rfc822()
 	{
 		$this->assertEquals(
-			date('D, d M y H:i:s O', $this->time),
+			date(DATE_RFC822, $this->time),
 			standard_date('DATE_RFC822', $this->time)
 		);
 	}
@@ -79,7 +79,7 @@
 	public function test_standard_date_atom()
 	{
 		$this->assertEquals(
-			date('Y-m-d\TH:i:sP', $this->time),
+			date(DATE_ATOM, $this->time),
 			standard_date('DATE_ATOM', $this->time)
 		);
 	}
@@ -89,7 +89,7 @@
 	public function test_standard_date_cookie()
 	{
 		$this->assertEquals(
-			date("l, d-M-y H:i:s \U\T\C", $this->time),
+			date(DATE_COOKIE, $this->time),
 			standard_date('DATE_COOKIE', $this->time)
 		);
 	}
@@ -99,7 +99,7 @@
 	public function test_standard_date_iso8601()
 	{
 		$this->assertEquals(
-			date('Y-m-d\TH:i:sP', $this->time),
+			date(DATE_ISO8601, $this->time),
 			standard_date('DATE_ISO8601', $this->time)
 		);
 	}
@@ -109,7 +109,7 @@
 	public function test_standard_date_rfc850()
 	{
 		$this->assertEquals(
-			date("l, d-M-y H:i:s \U\T\C", $this->time),
+			date(DATE_RFC850, $this->time),
 			standard_date('DATE_RFC850', $this->time)
 		);
 	}
@@ -119,7 +119,7 @@
 	public function test_standard_date_rfc1036()
 	{
 		$this->assertEquals(
-			date('D, d M y H:i:s O', $this->time),
+			date(DATE_RFC1036, $this->time),
 			standard_date('DATE_RFC1036', $this->time)
 		);
 	}
@@ -129,7 +129,7 @@
 	public function test_standard_date_rfc1123()
 	{
 		$this->assertEquals(
-			date('D, d M Y H:i:s O', $this->time),
+			date(DATE_RFC1123, $this->time),
 			standard_date('DATE_RFC1123', $this->time)
 		);
 	}
@@ -139,7 +139,7 @@
 	public function test_standard_date_rfc2822()
 	{
 		$this->assertEquals(
-			date('r', $this->time),
+			date(DATE_RFC2822, $this->time),
 			standard_date('DATE_RFC2822', $this->time)
 		);
 	}
@@ -149,7 +149,7 @@
 	public function test_standard_date_rss()
 	{
 		$this->assertEquals(
-			date('D, d M Y H:i:s O', $this->time),
+			date(DATE_RSS, $this->time),
 			standard_date('DATE_RSS', $this->time)
 		);
 	}
@@ -159,7 +159,7 @@
 	public function test_standard_date_w3c()
 	{
 		$this->assertEquals(
-			date('Y-m-d\TH:i:sP', $this->time),
+			date(DATE_W3C, $this->time),
 			standard_date('DATE_W3C', $this->time)
 		);
 	}