For lights you can use this.solar_time function in aircraft script, that returns {time, sun_coef} object, defined as:
//@param time [out] solar time at vehicle location, in miliseconds
//@param sun_coef sun position relative to horizon: 0 sun at horizon, 1 sun at zenith, -1 sun at anti-zenith
T817 script has an example of automatic lights using the sun_coef value.
Even though you can access the env interface from javascript (var env = this.$query_interface("ot::js::environment.get")), it will likely go away soon, because it would allow aircraft to mess with global settings which is not desirable. There should be some kind of sensors api for environment sensing instead.