Adiabatic and nonadiabatic evolution of electromagnetic waves propagating in time-dependent linear media