bluefireteam / daylight Goto Github PK
View Code? Open in Web Editor NEWGet the sunset and sunrise times for a geolocation without having to access any api.
License: MIT License
Get the sunset and sunrise times for a geolocation without having to access any api.
License: MIT License
Hello,
Thanks for a very useful library.
I have found that the calculated date time is off by 30 mins and hence we need to add this to get the correct value after calculation. Here's what I ended up writing:
SunTime _fromLibrary2({DateTime dateTime}) {
//uses this package: daylight
berlin();
//const lc = const DaylightLocation(52.518611, 13.408056);
final lc = DaylightLocation(latitude, longitude);
// Create lc calculator
final lcCalculator = DaylightCalculator(lc);
//this is the closest, but still early by 30 mins
final daylightResult =
lcCalculator.calculateForDay(dateTime ?? DateTime.now());
//correct the difference of 30 mins
return new SunTime(
daylightResult.sunrise.round().add(Duration(minutes: 30)),
daylightResult.sunset.round().add(Duration(minutes: 30)));
}
/// Result of SunriseSunset calculation
class SunTime {
/// Construnctor method
SunTime(this.sunrise, this.sunset);
/// Time of the sunrise
DateTime sunrise;
/// Time of the sunset
DateTime sunset;
String localSunriseDisplay() =>
'${sunrise.toLocal().hour}:${sunrise.toLocal().minute}';
String localSunsetDisplay() =>
'${sunset.toLocal().hour}:${sunset.toLocal().minute}';
@override
String toString() =>
'Sunrise: $localSunriseDisplay, Sunset: $localSunsetDisplay';
}
extension Round on DateTime {
DateTime round({roundAtSeconds = 30}) {
var factor =
this.second <= roundAtSeconds ? (-1 * this.second) : (60 - this.second);
return this.add(Duration(seconds: factor));
}
}
Can you please confirm if this is so. And if the issue is correct, kindly update the package.
Have tried using package with very basic implementation, but is seems always gets data wrong to 3 hours. I think it doesn't calculate UTC + hours. Do i need to do it myself and if so, how better achieve this?
Because daylight 2.0.0 depends on intl ^0.17.0 and no versions of daylight match >2.0.0 <3.0.0, daylight ^2.0.0 requires intl ^0.17.0.
So, because XXX depends on both intl ^0.18.0 and daylight ^2.0.0, version solving failed.
When using calculateEvent
or calculateForDay
of the DaylightCalculator
and using an input DateTime
which already is UTC, the results are offset from the correct time by the difference between local and utc.
You should be able to easily reproduce this problem by using, e.g. final todayUtc = DateTime.utc(2020, 1, 19)
as the input.
version: 1.0.0
I compare a time in sunrise-sunset API with your package.
In sunset in the same time in my location (39.4699014, -0.3759513), day 2020-03-03 and Zennit default (official).
But in sunrise, have a litle difference of 56 seconds . This is a screenshots and values
API - Sunrise 07:29:48:
Package - Sunrise 07:30:44:
OBS: This is a minor issue and I'll use this package because is awesome :)
I am using day package in my app and now after upgrading to latest flutter sdk i am unable to use the day light package.
error message I get is the following.
Because no versions of daylight match >0.2.0 <0.3.0 and daylight 0.2.0 depends on intl ^0.16.1, daylight ^0.2.0 requires intl ^0.16.1.
And because every version of flutter_localizations from sdk depends on intl 0.17.0, daylight ^0.2.0 is incompatible with flutter_localizations from sdk.
So, because tiremoni depends on both flutter_localizations any from sdk and daylight ^0.2.0, version solving failed.
pub get failed (1; So, because tiremoni depends on both flutter_localizations any from sdk and daylight ^0.2.0, version solving failed.)
Because daylight 2.0.0 depends on intl ^0.17.0 and no versions of daylight match >2.0.0 <3.0.0, daylight ^2.0.0 requires intl ^0.17.0.
So, because XXX depends on both intl ^0.18.0 and daylight ^2.0.0, version solving failed.
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.