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

Add test for variety of date/time stamps #123

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update test.js
  • Loading branch information
alexburner authored Dec 24, 2018
commit eb562d953c602fdaf88d64d3ce025303cede9e9a
14 changes: 6 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
@@ -72,18 +72,16 @@ t.test('getMoonTimes returns moon rise and set times', function (t) {
});

t.test('getTimes day detection works with a variety of date times', function (t) {
var latitude = 47.606209;
var longitude = -122.332069;
var targetDay = 4;
var dateStrings = [
var lat = 47.606209;
var lng = -122.332069;
var testDateDay = 4;
var testDateStrings = [
'Mon, 04 Mar 2013 00:00:01 PDT',
'Mon, 04 Mar 2013 12:00:00 PDT',
'Mon, 04 Mar 2013 23:59:59 PDT'
];
for (var i = 0, l = dateStrings.length; i < l; i++) {
var dateString = dateStrings[i];
var date = new Date(dateString);
var times = SunCalc.getTimes(date, latitude, longitude);
t.equal(times.solarNoon.getDate(), targetDay, dateString);
var times = SunCalc.getTimes(new Date(testDateStrings[i]), lat, lng);
t.equal(times.solarNoon.getDate(), testDateDay, testDateStrings[i]);
}
});