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

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

Daylight #

Pub style: very good analysis License: MIT

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

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

Installation ๐Ÿ’ป #

โ— In order to start using Daylight you must have the Dart SDK installed on your machine.

Add daylight to your pubspec.yaml:

dependencies:
  daylight:

Install it:

dart pub get

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 unless you live near the north pole or south pole


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

Running Tests ๐Ÿงช #

To run all unit tests:

dart pub global activate coverage 1.2.0
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info

To view the generated coverage report you can use lcov.

# Generate Coverage Report
genhtml coverage/lcov.info -o coverage/

# Open Coverage Report
open coverage/index.html
33
likes
130
pub points
81%
popularity

Publisher

verified publisherblue-fire.xyz

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

Repository (GitHub)
View/report issues

Topics

#daylight #time #location #timezone

Documentation

API reference

License

MIT (LICENSE)

Dependencies

equatable, intl

More

Packages that depend on daylight