/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/LightSwitch/LightSwitchService/LightSwitchUtils.h
24 строки
910 B
Jaylyn Barbee
[Light Switch] Enter latitude and longitude manually in Sunrise to sunset mode (#43276)
12 ноя 2025, 00:18
Не верифицирован
12 ноя 2025, 00:18
29688ce
Код
Авторство
О чём код?
#pragma once #include <windows.h> constexpr bool ShouldBeLight(int nowMinutes, int lightTime, int darkTime) { // Normalize values into [0, 1439] int normalizedLightTime = (lightTime % 1440 + 1440) % 1440; int normalizedDarkTime = (darkTime % 1440 + 1440) % 1440; int normalizedNowMinutes = (nowMinutes % 1440 + 1440) % 1440; // Case 1: Normal range, e.g. light mode comes before dark mode in the same day if (normalizedLightTime < normalizedDarkTime) return normalizedNowMinutes >= normalizedLightTime && normalizedNowMinutes < normalizedDarkTime; // Case 2: Wrap-around range, e.g. light mode starts in the evening and dark mode starts in the morning return normalizedNowMinutes >= normalizedLightTime || normalizedNowMinutes < normalizedDarkTime; } inline int GetNowMinutes() { SYSTEMTIME st; GetLocalTime(&st); return st.wHour * 60 + st.wMinute; }