A Q-switched oscillator for stable time-tunable operation in the nanosecond regime