unsoluble / smalltime

A small FoundryVTT module for displaying and controlling the current time of day.
MIT License
23 stars 15 forks source link

[Suggestion] Sunrise/Sunset daily variation (Simple Calendar integration) #136

Closed Txus5012 closed 1 year ago

Txus5012 commented 2 years ago

Hi. Great work with this module!

I'm using it mainly to get a Day-Night cycle and the integration with Simple Calendar is great. I noticed that the sunrise/sunset time used is the one we write in the Season tab of SC. Is it possible to make the sunrise/sunset time be the one that SC calculates for each day instead of having the same times all the season?

unsoluble commented 2 years ago

Hmm. As far as I can tell, Simple Calendar doesn't expose the current gradually-calculated sunrise/sunset times via its API. But perhaps it's hiding somewhere and @vigoren can tell me where to look. :)

vigoren commented 2 years ago

The sunrise/sunset times for a specific date are available through the DateTimeChange hook in Simple Calendar in the data.date.sunrise property (assuming the parameter for the hook function is called data). These values take into account the gradual change as the seasons pass.

These values are timestamps not the seconds specific to the day. Example: the value of 1654495200 for June 6th 6:00am vs a value of 21600 for 6:00am

The function timestampToDate returns the same data for the passed in timestamp, though I feel this wouldn't be as useful for what you are looking for.

If neither of these options work for your needs, what would make your life easier? I am happy to add something to the API.

unsoluble commented 1 year ago

Implemented in 1.15.0