0

I have this code to make conversion :

var date = new Date(1900, 0, 0, 0, 0, 0);
date.setDate(date.getDate() + row.values[1]);
var heure = row.values[5].toString().split(':');
date.setHours(heure[0]);
date.setMinutes(heure[1]);
console.log(date.toString());

Where row.values1 containe date in excel format. This function return the day next initial date, why?

EDIT Date object doesn't benchmark the 1900 year like a leap year

var date = new Date(1900, 0, 0, 0, 0, 0);
date.setDate(date.getDate() + 59);

Give me: Wed Feb 28 1900

var date = new Date(1900, 0, 0, 0, 0, 0);
date.setDate(date.getDate() + 60);

Give me: Thu Mar 01 1900

Maybe a javascript bug?

EDIT In microsoft excel 2007 29/02/1900 is a valid date instead of 1900 isn't a leap year

see http://support.microsoft.com/kb/214326 for more details

momolechat
  • 155
  • 11

1 Answers1

0

A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. :p

Hiren S.
  • 2,793
  • 15
  • 25