Skip to content

thatsIch/solar-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solar Time

Java Library, Calculate solar times like solar noon, sunrise, sunset, astronomical, nautical and civil dawn/dusks


This work is heavily inspired by https://github.com/caarmen/SunriseSunset. The fundamental changes are:

  • requires Java 11+,
  • usage of Java 8 Time API (ZonedDateTime instead of Calendar),
  • splitting return results of dawn and dusk and
  • usage of Optional because Empty is a valid result for solar times.

Project Status

Maintenance

Build Status

Codecov Coverage Coverage Status Coverage

Quality Gate Status Security Rating Technical Debt Maintainability

Example Usage

Entrypoint is the API. You can instatiate it via new API() to retrieve the SolarTime and SunStateChecker endpoints.

final var api = new API();
final var solarTime = api.getSolarTime();

final var now = ZonedDateTime.now();
final var latitude = 51.449680;
final var longitude = 6.973370;

solarTime.calculateNauticalDawn(now, latitude, longitude)
        .map(dateTime -> dateTime.withZoneSameInstant(ZoneId.systemDefault()))
        .map(ZonedDateTime::toLocalDateTime)
        .ifPresent(time -> LOGGER.info("Nautical Dawn: " + time));

INFO: Nautical Dawn: 2019-06-25T03:15:46

final var sunStateChecker = api.getSunStateChecker();
LOGGER.info("is 24-hour day: " + sunStateChecker.is24HourDayTime(now, latitude, longitude));

INFO: is 24-hour day: false

For more examples check the wiki

About

Java Library, Calculate solar times like solar noon, sunrise, sunset, astronomical, nautical and civil dawn/dusks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages