Browse Source

Fixed leap year code

There was a problem with how the code handled weather data for same day last year when the last year was a leap year.
Josh Smith 8 years ago
parent
commit
89976f6d2f
1 changed files with 8 additions and 1 deletions
  1. 8 1
      index.html.tmpl

+ 8 - 1
index.html.tmpl

@@ -225,7 +225,14 @@
 				#end if
 			#end if
 		    #else
-		    	#set $n = 365
+			#set $yrNew = $yr - 1
+			#if $yrNew % 100 == 0
+				#if $yrNew % 400 == 0
+					#set $n = 366
+				#end if
+			#else
+		    		#set $n = 365
+			#end if
 		    #end if
 		    
 		    <h1><i class="fa fa-history" ></i> Last $days_ago($days_ago=$n).dateTime.format("%d-%b (%Y)")</h1>