Time-dependent density functional theory applied to x-ray absorption spectroscopy