This is the first function we'll take a crack at refactoring. We're not able to write unit tests for the current implementation so this will be a great starter.
const moment = require('moment')
const currentYear = (
moment()
.format('YYYY')
)
const isHalloween = () => (
moment()
.isBetween(
`${currentYear}-10-31 16:00`,
`${currentYear}-10-31 23:30`
)
)
module.exports = isHalloween