Safety quantification for nonlinear and time-delay systems using occupation measures