日光
无需访问任何 API 即可获取地理位置的日出和日落时间。
- 星标
- 64
- 复刻
- 13
- 最近推送(UTC)
- 2026年2月17日
- 项目状态
- 未归档
原始 README
以下为英文项目原文快照,最新内容请访问 GitHub。
Daylight
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.
Install it:
dart pub add daylight
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()));
语言Dart
使用的依赖
依赖清单 5 项
- equatable
^2.0.5 - intl开发依赖
>=0.19.0 <0.21.0 - mocktail开发依赖
^1.0.0 - test开发依赖
^1.19.2 - very_good_analysis开发依赖
>=5.1.0 <8.0.0
如何选择适合项目的代码仓?
先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
- 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
- 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
- 使用前在 GitHub 核对 README、许可证与 Issues。
来源与维护
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗