Second, ordinary window glass blocks these useful wavelengths, which are in the ultraviolet-B range.

Third, even if the window were wide open to the sunlight, the angle at which the sun’s rays hit the planet in northern latitudes in the winter means that it is hard, if not impossible, for many Northerners to get enough winter sunshine to meet their vitamin D requirements, even with prolonged exposure.

While the useful wavelengths are blocked by window glass, ultraviolet-A wavelengths associated with skin cancer easily pass through the glass. It has even been suggested that fair-skinned indoor workers may show a higher risk of melanoma for this reason.

Luckily, a vitamin D deficit can be made up through some foods (especially oily fish), fortified foods and supplements.

The most valuable ultraviolet-B wavelengths of sunlight, 290 to 320 nanometers, are plentiful in summer. Because of the skin cancer risks associated with all ultraviolet radiation, getting vitamin D through sunbathing is a balancing act.

For fair-skinned people, short exposure to the summer sun twice a week for the face, arms, hands or back — less time than it takes to turn the skin pink — is enough to get the vitamin D benefits. Dark-skinned people need much longer exposure because of the higher levels of the protective pigment melanin.