daylight 2.0.0 copy "daylight: ^2.0.0" to clipboard
daylight: ^2.0.0 copied to clipboard

Get the sunset and sunrise times for a geolocation without having to access any api.

Dart Daylight #

Pub Tests status

Get the sunset and sunrise times for a geolocation without having to access any api.

This is a simple implementation of the legendary Sunset/Sunrise algorithm.

Usage #

Check the API docs, example and tests for more information about how to use it.

import 'package:daylight/daylight.dart';


final berlin = DaylightLocation(52.518611, 13.408056);
final berlinCalculator = DaylightCalculator(berlin);
final dailyResults = berlinCalculator.calculateForDay(DateTime.now(), Zenith.astronomical);
print(dailyResults.sunrise); // Some UTC datetime with sunrise hours like 08:32
print(dailyResults.sunset);
print(dailyResults.type); // day type, will probably be sunriseAndSunset if you dont live near the poles


double eventHourEpoch = berlinCalculator.calculateEvent(DateTime.now(), Zenith.official, EventType.sunset);
print(DateTime.fromMillisecondsSinceEpoch(eventHourEpoch.floor()));

33
likes
120
pub points
81%
popularity

Publisher

verified publisherblue-fire.xyz

Get the sunset and sunrise times for a geolocation without having to access any api.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

angles, intl

More

Packages that depend on daylight