Fix auto-change theme based on hour

This commit is contained in:
Alfredo Vanegas 2022-01-22 10:16:06 -06:00
parent 98ea570473
commit bb240b5212
2 changed files with 5 additions and 3 deletions

View File

@ -57,7 +57,9 @@ if(CONFIG.changeThemeByOS && CONFIG.autoChangeTheme) {
if(CONFIG.changeThemeByHour && CONFIG.autoChangeTheme) { if(CONFIG.changeThemeByHour && CONFIG.autoChangeTheme) {
const date = new Date(); const date = new Date();
const currentTime = date.getHours().toString() + ':' + date.getMinutes().toString() const hours = date.getHours() < 10 ? '0' + date.getHours().toString() : date.getHours().toString();
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes().toString() : date.getMinutes().toString();
const currentTime = hours + ':' + minutes;
if(currentTime >= CONFIG.hourDarkThemeActive) { if(currentTime >= CONFIG.hourDarkThemeActive) {
enableDark(); enableDark();
} else if (currentTime >= CONFIG.hourDarkThemeInactive) { } else if (currentTime >= CONFIG.hourDarkThemeInactive) {

View File

@ -32,12 +32,12 @@ const CONFIG = {
defaultLatitude: '37.775', defaultLatitude: '37.775',
defaultLongitude: '-122.419', defaultLongitude: '-122.419',
// Autochange dark-theme (24hrs format) // Autochange dark-theme (24hrs format, string must be in: hh:mm)
autoChangeTheme: true, autoChangeTheme: true,
changeThemeByOS: false, changeThemeByOS: false,
changeThemeByHour: true, changeThemeByHour: true,
hourDarkThemeActive: '19:00', hourDarkThemeActive: '19:00',
hourDarkThemeInactive: '7:00', hourDarkThemeInactive: '07:00',
// ┌─┐┌─┐┬─┐┌┬┐┌─┐ // ┌─┐┌─┐┬─┐┌┬┐┌─┐
// │ ├─┤├┬┘ ││└─┐ // │ ├─┤├┬┘ ││└─┐