Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GETTIMES returning invalid sunrise sunset even after correct inputs #146

Open
Chetna124 opened this issue Jun 14, 2020 · 2 comments
Open

Comments

@Chetna124
Copy link

var date = new Date('2020-06-11T20:24:46.426Z');
getTimes(date,'66.09639074589798','29.714674589159888');

Result:
{
solarNoon: 2020-06-11T10:02:13.573Z,
nadir: 2020-06-10T22:02:13.573Z,
sunrise: Invalid Date,
sunset: Invalid Date,
sunriseEnd: 2020-06-10T22:51:46.384Z,
sunsetStart: 2020-06-11T21:12:40.761Z,
dawn: Invalid Date,
dusk: Invalid Date,
nauticalDawn: Invalid Date,
nauticalDusk: Invalid Date,
nightEnd: Invalid Date,
night: Invalid Date,
goldenHourEnd: 2020-06-11T01:10:09.689Z,
goldenHour: 2020-06-11T18:54:17.457Z
}

Really not able to understand why.

@scgrant327
Copy link

Agreed, seeing the same thing with:
sunTimes = SunCalc.getTimes(new Date(), 30.5, -86.5)

dawn: Invalid Date {}
dusk: Invalid Date {}
goldenHour: Invalid Date {}
goldenHourEnd: Invalid Date {}
nadir: Mon Dec 14 2020 23:42:39 GMT-0600 (Central Standard Time) {}
nauticalDawn: Invalid Date {}
nauticalDusk: Invalid Date {}
night: Invalid Date {}
nightEnd: Invalid Date {}
solarNoon: Tue Dec 15 2020 11:42:39 GMT-0600 (Central Standard Time) {}
sunrise: Invalid Date {}
sunriseEnd: Invalid Date {}
sunset: Invalid Date {}
sunsetStart: Invalid Date {}
__proto__: Object

@knut-forkalsrud
Copy link

var date = new Date('2020-06-11T20:24:46.426Z'); getTimes(date,'66.09639074589798','29.714674589159888');

You are very close to the Polar circle, and also close to mid summer.

In the code, sunrise seems to be when the sun's elevation crosses -0.833 degrees.

var times = SunCalc.times = [
    [-0.833, 'sunrise',       'sunset'      ],
    [  -0.3, 'sunriseEnd',    'sunsetStart' ],
    [    -6, 'dawn',          'dusk'        ],
    [   -12, 'nauticalDawn',  'nauticalDusk'],
    [   -18, 'nightEnd',      'night'       ],
    [     6, 'goldenHourEnd', 'goldenHour'  ]
];

Looking at your coordinates, it appears the sun never got below that limit. You have in effect midnight sun.

times = SunCalc.getTimes(new Date('2020-06-11T20:24:46.426Z'),66.09639074589798,29.714674589159888);
SunCalc.getPosition(times.nadir, 66.09639074589798,29.714674589159888).altitude * 180 / Math.PI;
-0.8314978114031835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants