UZYTAK

Open source · MIT licence

uzytak_sun_moon

Sunrise, sunset, moonrise, moonset, Moon phase and illumination for any place on Earth. Pure Dart, no dependencies, works in Flutter and in command-line Dart.

Адкрыты код: усход і захад Сонца і Месяца, фаза Месяца.Otwarty kod: wschód i zachód Słońca i Księżyca, faza Księżyca.

What it is

Our own implementation of public astronomical formulas: the NOAA solar equations and the Meeus low-precision lunar theory with topocentric parallax. It was written for the Belarusian tear-off calendar and is now open, so that anyone can use it and check it.

Accuracy against Swiss Ephemeris

Compared with Swiss Ephemeris 2.10.03 on 12 places (Warsaw, Minsk, New York, Sydney, Quito, Singapore, Buenos Aires, Reykjavik, Fairbanks, Tromsø, Murmansk, Longyearbyen) and 24 dates between January 2026 and August 2028: 288 place-days. Rise and set mean the upper limb at the horizon with standard refraction.

QuantityCompared valuesMean error95th percentileMaximum error
Sunrise and sunset, latitude up to 65°4320.08 min0.21 min0.62 min
Sunrise and sunset, latitude above 65°780.19 min0.45 min1.27 min
Moonrise and moonset, latitude up to 65°4000.07 min0.16 min0.57 min
Moonrise and moonset, latitude above 65°730.19 min0.61 min0.81 min
Moon illuminated fraction2880.009 pp0.018 pp0.019 pp

Two moon events within 3 minutes of the edge of the compared 24-hour window are left out. In every other case the package and the reference agree on whether an event exists at all. The numbers are measured by the test tool in the package; they describe these places and years, not a guarantee for every place and date. For calendars and planners, not for navigation.

Install and use

dart pub add uzytak_sun_moon
import 'package:uzytak_sun_moon/uzytak_sun_moon.dart';

void main() {
  const lat = 52.2297, lng = 21.0122; // Warsaw

  // Sun: any instant near the middle of the wanted day
  final sun = sunTimes(DateTime.utc(2026, 11, 15, 12), lat, lng);
  if (!sun.polar) print('${sun.rise} ${sun.set}'); // UTC instants

  // Moon: the 24 hours that start at the given instant
  final moon = moonTimes(DateTime.utc(2026, 11, 15), lat, lng);
  print('${moon.rise} ${moon.set}'); // either can be null

  final ill = moonIllumination(DateTime.utc(2026, 11, 15, 12));
  print('${(ill.fraction * 100).toStringAsFixed(1)} % lit');
}

Good to know

Licence

MIT. Free for any use, also commercial. Keep the notice below in your copy.

MIT License

Copyright (c) 2026 UZYTAK

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.