Comments (1)
Hi Tal! Thanks for the report and including a test, super helpful! Apologies for the delay.
I've had a look at your test and as far as I can tell it seems to be working as expected, in that it always returns a UTC date that you have to format 🤔 maybe I am misunderstanding though. I've added a little debug code to the bottom of your test. Can you check my logic:
func testLateTimeCorrectReturnDate() {
let lateTime = Date(timeIntervalSince1970: 1499130000) // Tuesday, 4 July 2017 01:00:00 UTC
let city = cities.first(where: { $0.name == "Washington, D. C." })!
let calendar: Calendar = {
var calendar = Calendar.current
calendar.timeZone = TimeZone(identifier: "EST")!
return calendar
}()
guard let solar = Solar(for: lateTime, latitude: city.latitude, longitude: city.longitude) else {
XCTFail("Cannot get solar")
return
}
let sameDate = calendar.compare(lateTime, to: solar.sunset!, toGranularity: .day)
XCTAssertTrue(sameDate == .orderedSame, "The sunset given \(solar.sunset!) is not same day as given date \(lateTime)")
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .full
dateFormatter.timeStyle = .full
dateFormatter.timeZone = TimeZone(identifier: "EST")!
let string = dateFormatter.string(from: solar.sunset!)
print("Date: \(string)")
}
This outputs Date: Tuesday, July 4, 2017 at 7:36:56 PM GMT-05:00
. I've had a look this reference website and can see that the local sunset is July 4th 8:36pm GMT-04:00 (EDT). This looks to me that it's producing the correct sunset date given the 1 hour DST difference between EST and EDT.
After running your pull request test and checking Solar's date, I get:
2017-07-04 00:37:07 +0000
. The timezone here is UTC, so when we format this date to EST we actually get a date on 2017-07-03.
Tell me if I'm missing something! 🙈
from solar.
Related Issues (20)
- Needs more Swift
- isNighttime calculation incorrect HOT 4
- Solar Noon HOT 1
- error when excute carthage update HOT 4
- Daylight Saving time HOT 1
- Adding of 1 day to sunrise and sunset times happens too early HOT 6
- Support installation via Carthage for macOS and tvOS
- Is it possible to get the times for a given sun position on a given date ? HOT 2
- Data used is inconsistent with other sources
- Xcode 10 build error HOT 2
- Day Light Saving Issue HOT 1
- Update documentation HOT 1
- Sunrise and Sunset dates off by 1 day. HOT 3
- Cocoapods 'stuck at v.2.1' HOT 5
- Return only time HOT 1
- Xcode 12.5 Build Warning HOT 3
- isDaytime and isNightTime return incorrect values for polar day HOT 1
- WeatherKit HOT 3
- Mismatched times when device timezone and input lat/lon are different
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solar.