[pLog-svn] r6652 - plog/branches/lifetype-1.2/class/test/tests/locale

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Mon Jun 23 13:00:41 EDT 2008


Author: jondaley
Date: 2008-06-23 13:00:41 -0400 (Mon, 23 Jun 2008)
New Revision: 6652

Modified:
   plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php
Log:
test now works during daylight savings time too.  There are now two tests, one for non-daylight savings time, and one for daylight savings time (assuming that february is non-DST, and june is DST)

Modified: plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php	2008-06-23 16:48:49 UTC (rev 6651)
+++ plog/branches/lifetype-1.2/class/test/tests/locale/locale_test.class.php	2008-06-23 17:00:41 UTC (rev 6652)
@@ -77,13 +77,51 @@
 		
 		/**
 		 * Tests that the Locale::testFormatDateGMT() method also behaves
+		 * as expected during daylight savings time
+		 */
+		function testFormatDateGMT_DST()
+		{
+			$d = new Timestamp( "20070605180000" );
+			
+			$diff = $this->l->formatDate( $d, "%O" );
+            $diff = $diff / 100;
+
+			$this->assertEquals( "Tue", $this->l->formatDateGMT( $d, "%a" ));
+			$this->assertEquals( "Tuesday", $this->l->formatDateGMT( $d, "%A" ));
+			$this->assertEquals( "Jun", $this->l->formatDateGMT( $d, "%b" ));
+			$this->assertEquals( "June", $this->l->formatDateGMT( $d, "%B" ));
+			$this->assertEquals( "05", $this->l->formatDateGMT( $d, "%d" ));
+			$this->assertEquals( "5", $this->l->formatDateGMT( $d, "%j" ));
+			$this->assertEquals( 18-$diff, $this->l->formatDateGMT( $d, "%H" ));
+			$this->assertEquals( (18-$diff)%12, $this->l->formatDateGMT( $d, "%I" ));
+			$this->assertEquals( "pm", $this->l->formatDateGMT( $d, "%p" ));			
+			$this->assertEquals( "PM", $this->l->formatDateGMT( $d, "%P" ));						
+			$this->assertEquals( "00", $this->l->formatDateGMT( $d, "%M" ));			
+			$this->assertEquals( "06", $this->l->formatDateGMT( $d, "%m" ));
+			$this->assertEquals( "00", $this->l->formatDateGMT( $d, "%S" ));
+			$this->assertEquals( "07", $this->l->formatDateGMT( $d, "%y" ));			
+			$this->assertEquals( "2007", $this->l->formatDateGMT( $d, "%Y" ));
+			$this->assertEquals( "%", $this->l->formatDateGMT( $d, "%%" ));
+			$this->assertEquals( "5th of June", $this->l->formatDateGMT( $d, "%T" ));			
+			$this->assertEquals( "5th", $this->l->formatDateGMT( $d, "%D" ));	
+			
+			// a longer format test
+			$this->assertEquals( "Jun ", $this->l->formatDateGMT( $d, "%b " ));
+			$this->assertEquals( "Jun 5", $this->l->formatDateGMT( $d, "%b %j" ));
+			$this->assertEquals( "05/06/2007", $this->l->formatDateGMT( $d, "%d/%m/%Y" ));
+			$this->assertEquals( "05 June, 2007 ".(18-$diff).":00", $this->l->formatDateGMT( $d, "%d %B, %Y %H:%M" ));								
+		}		
+
+		
+		/**
+		 * Tests that the Locale::testFormatDateGMT() method also behaves
 		 * as expected
 		 */
 		function testFormatDateGMT()
 		{
 			$d = new Timestamp( "20070205120000" );
 			
-			$diff = $this->l->formatDate( new Timestamp(), "%O" );
+			$diff = $this->l->formatDate( $d, "%O" );
             $diff = $diff / 100;
 
 			$this->assertEquals( "Mon", $this->l->formatDateGMT( $d, "%a" ));
@@ -93,7 +131,7 @@
 			$this->assertEquals( "05", $this->l->formatDateGMT( $d, "%d" ));
 			$this->assertEquals( "5", $this->l->formatDateGMT( $d, "%j" ));
 			$this->assertEquals( 12-$diff, $this->l->formatDateGMT( $d, "%H" ));
-			$this->assertEquals( "5", $this->l->formatDateGMT( $d, "%I" ));
+			$this->assertEquals( (12-$diff)%12, $this->l->formatDateGMT( $d, "%I" ));
 			$this->assertEquals( "pm", $this->l->formatDateGMT( $d, "%p" ));			
 			$this->assertEquals( "PM", $this->l->formatDateGMT( $d, "%P" ));						
 			$this->assertEquals( "00", $this->l->formatDateGMT( $d, "%M" ));			
@@ -111,5 +149,6 @@
 			$this->assertEquals( "05/02/2007", $this->l->formatDateGMT( $d, "%d/%m/%Y" ));
 			$this->assertEquals( "05 February, 2007 ".(12-$diff).":00", $this->l->formatDateGMT( $d, "%d %B, %Y %H:%M" ));								
 		}		
-	}
+
+    }
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list