1

I'm having a weird situation. Recently I've moved from Azure cloud to Digital Ocean server. I'm using Nodejs version v10.15.0 and Centos 7.

My timedatectl output is

[deploy@prod-ca-api install-scripts]$ timedatectl
Local time: Tue 2019-03-19 15:34:21 IST
Universal time: Tue 2019-03-19 10:04:21 UTC
RTC time: Tue 2019-03-19 10:04:21
Time zone: Asia/Kolkata (IST, +0530)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
[deploy@prod-ca-api install-scripts]$ 

The output of date by setting the hours to start of the day is giving me proper output for the current date. But the same is responding with 24 minutes difference for dates below the year 1900.

My timezone setting is in IST (+5.30)

[deploy@prod-ca-api install-scripts]$ date
Tue Mar 19 15:36:57 IST 2019
[deploy@prod-ca-api install-scripts]$ node
> let a = new Date()
undefined
> a.setHours(0,0,0,0)
1552933800000
> a
2019-03-18T18:30:00.000Z
> a = new Date('1700-01-01')
1700-01-01T00:00:00.000Z
> a.setHours(0,0,0,0)
-8520357208000
> a
1699-12-31T18:06:32.000Z

Previously in Azure servers, I used to get 1699-12-31T18:30:00.000Z instead of 1699-12-31T18:06:32.000Z

Deepan
  • 13

1 Answers1

1

I think that the right time should in fact be 18:06. I made this conclusion after I read this article: https://www.dailyo.in/variety/indian-standard-time-time-zones-bagan-time/story/1/17080.html

Relevant parts of this article are:

Indian Standard Time, which is observed in India and well, not too strangely in neighbouring Sri Lanka where they call it the Sri-Lanka Standard Time, has an offset of UTC+05:30.

This is clear and easy to understand.

India had no official time zone till 1906; we had three presidencies: Bombay, Calcutta, Madras, and three local times for the three cities, depending on where they fell on the longitude. The three time zones, thus created, were followed by all the states or cities around and near it.

This is where it gets interesting. India apparently didn't have official time zone until January 1st 1906. Which is in line with your empirical research.

Calcutta was set at UTC+05.54, making it +00:24 of the current IST.

This would explain the strange behavior in NodeJS (kind of). Again in line with your research.

There is a lot more to this history, but anyway I would conclude that the time could be correct in both of these cases. It's very hard to determine precise time for these old dates, because the whole time zone didn't even exist. In general you shouldn't be trusting old dates, because time zones can be really confusing and countries might have also been using different calendars. Also there are no realistic use cases for using dates in 1600s for example.