triggertrap / sun-js Goto Github PK
View Code? Open in Web Editor NEWCalculate sunrise and sunset times in Javascript
Calculate sunrise and sunset times in Javascript
I'm not sure if this is a bug or if I'm doing something wrong, but often I get the wrong sunset time, I will get the sunset of the previous day. I am working with a date that has been set to midnight of the current day using the following small function
function midnightify(time){ var new_time = new Date(time.getTime()); new_time.setHours(0); new_time.setMinutes(0); new_time.setSeconds(0); new_time.setMilliseconds(0); return new_time; }
when the following code is run
var lat = 41.116049; var lon = -73.782147; var current_time = new Date(); var midnight = midnightify(current_time); var sunset = midnight.sunset(lat, lon);
current time has the value of "Sat Jun 02 2018 13:58:43 GMT-0400 (EDT)"
midnight has the value of "Sat Jun 02 2018 00:00:00 GMT-0400 (EDT)"
sunset has the value of "Fri Jun 01 2018 20:21:10 GMT-0400 (EDT)"
It does not make sense to me that the sunset for the day of June 2nd would happen on June 1st. Let me know if I am just misconceiving something here.
When I find the sunrise and sunset time with respect to my current location, sunrise is calculated with tomorrow's date instead of today's date.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.