Attosecond time–energy structure of X-ray free-electron laser pulses