ChatGPT deu uma refatorada

setBackground() {
  const agora = new Date() // Obtém a data e hora atual
  const hora = agora.getHours() // Obtém a hora atual (0-23)

  const cores = {
    manha: { background: '#FFF9C4' },
    tarde: { background: '#FFE0B2' },
    noite: { background: '#263238', textColor: 'white' },
    madrugada: { background: '#212121', textColor: 'white' },
  }

  let cor = ''

  if (hora >= 6 && hora < 12) {
    cor = 'manha'
  } else if (hora >= 12 && hora < 18) {
    cor = 'tarde'
  } else if (hora >= 18 && hora < 22) {
    cor = 'noite'
  } else {
    cor = 'madrugada'
  }

  this.background = cores[cor].background
  this.textColor = cores[cor].textColor || ''
}

obrigado pela contribuição! Vou aproveitar seu comentário para refatorar meu código.