solar-calculator icon indicating copy to clipboard operation
solar-calculator copied to clipboard

README needs clarification for Date objects in #noon, #rise, and #set

Open pmlord opened this issue 7 years ago • 1 comments

I was wondering if you could clarify the input and returned Date objects for the #noon, #rise, and #set functions in the README

Two sources for confusion:

  • input Date: My understanding is that the input Date is floored to the UTC day boundary. This can lead to unexpected results if the input Date has a UTC offset that puts it in a different day than the UTC.
// System timezone is EDT, UTC-04:00
d = new Date()          // => Mon Mar 12 2018 22:30:00 GMT-0400 (EDT)

// Sunrise for New York (returns the next day)
rise(d, 40.7, -74.0)    // => Tue Mar 13 2018 07:10:16 GMT-0400 (EDT)
  • return Date: The Date is returned in UTC, but JavaScript displays it in the system's local time, regardless.
// System timezone is EDT, UTC-04:00
d = new Date()          // => Mon Mar 12 2018 22:30:00 GMT-0400 (EDT)

// Sunrise for Los Angeles
rise(d, 34, -118)       // => Tue Mar 13 2018 10:04:24 GMT-0400 (EDT)

pmlord avatar Mar 12 '18 14:03 pmlord

@mbostock any clarification here is really well appreciated. And thank you so much for all this library!

BrodaNoel avatar Apr 01 '19 18:04 BrodaNoel