Error in calculating Timezone of Brasilia
<pre><code>function(startDate, lastDate){


var midDate = newDate(startDate.getFullYear(),startDate.getMonth(),Math.ceil((lastDate.getDate() + startDate.getDate()) / 2));

var startDateOffset = startDate.getTimezoneOffset();
var lastDateOffset = lastDate.getTimezoneOffset();
var midDateOffset = midDate.getTimezoneOffset();

var finalDate = new Date();
if(startDateOffset == midDateOffset){

  if((lastDate.getDate() - midDate.getDate()) &gt; 1){
    alert("loop");
  finalDate = this.getDaylightChangeDate(midDate, lastDate); 
  }
 }
</code></pre>

<p>I am getting start date as 20 oct , end date as 22nd and mid date again as 20th oct . This is happening only for the location Brasilia , also startDateOffset &amp; midDateOffset is 180 as output.. which is throwing the code in infinite loop as mid date is equal to start date always. Please suggest some other method in javascript to calculate the mid date</p>
