MCPcopy Create free account
hub / github.com/XIU2/UserScript / isDaytime

Function isDaytime

DarkMode.user.js:506–517  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

504
505 // 判断当前是白天还是晚上
506 function isDaytime() {
507 let nowTime = new Date('2022/03/07 ' + new Date().getHours() + ':' + new Date().getMinutes() + ':00').getTime()/1000, time = GM_getValue('menu_customTime').split('|');
508 time[0] = new Date('2022/03/07 ' + time[0] + ':00').getTime()/1000;
509 time[1] = new Date('2022/03/07 ' + time[1] + ':00').getTime()/1000;
510 if (time[0] < time[1]){
511 if (nowTime > time[0] && nowTime < time[1]) return true
512 return false
513 } else {
514 if (nowTime > time[0] || nowTime < time[1]) return true
515 return false
516 }
517 }
518})();

Callers 2

getAutoSwitchFunction · 0.85
addStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected