In animals, melatonin is involved in the entrainment (synchronization) of the circadian rhythms of physiological functions including sleep timing, blood pressure regulation, seasonal reproduction and many others.
...
It is principally blue light, around 460 to 480 nm, that suppresses melatonin,[24] proportional to the light intensity and length of exposure. Until recent history, humans in temperate climates were exposed to few hours of (blue) daylight in the winter; their fires gave predominantly yellow light. The incandescent light bulb widely used in the twentieth century produced relatively little blue light.[25] Kayumov et al. showed that light containing only wavelengths greater than 530 nm does not suppress melatonin in bright-light conditions.[26] Wearing glasses that block blue light in the hours before bedtime may decrease melatonin loss. Use of blue-blocking goggles the last hours before bedtime has also been advised for people who need to adjust to an earlier bedtime, as melatonin promotes sleepiness.[27]