Skip to content

About "DayNightChecker.ps1"

Fred Vatin edited this page Sep 18, 2025 · 3 revisions

Note

This script is used by the rainmeter config to determine if current time is in day or night period.

Edit this script with your favorite code editor. Between line 9 and 12:

switch ($month) {
  { $_ -in 3, 4, 5 } { $season = "Spring"; $sunrise = 6.5; $sunset = 20.0 }
  { $_ -in 6, 7, 8 } { $season = "Summer"; $sunrise = 5.5; $sunset = 21.0 }
  { $_ -in 9, 10, 11 } { $season = "Autumn"; $sunrise = 7.0; $sunset = 19.0 }
  default { $season = "Winter"; $sunrise = 8.0; $sunset = 17.0 }
}

set the sunrise and sunset time for the given season. Ask any AI those time in decimal 24h format for your region.

Run this script in pwsh 7 session and you’ll get an output like this:

Season : Autumn
Current Time : 20:25
Sunrise : 7.00
Sunset : 19.00
Result : night

Caution

Don’t edit the output or you could break the rainmeter skin that parses the result.


NEXT

Clone this wiki locally