Time-resolved fluorescence spectroscopy with programmable gating