Sparse space-time resolvent analysis for statistically-stationary and time-varying flows