In this paper we introduce the design of a digital time-varying filter to compensate the spurious in-band spectra caused by M-periodic nonuniform zero-order hold signals. For this purpose, a continuous-time framework to describe and analyze such signals is developed. Based on the error analysis, an equivalent discrete-time framework is derived and used for the design of a discrete-time time-varying precompensation filter. We exemplify the design of the precompensation filter for the two-periodic case through simulations and measurements. Furthermore, we discuss Farrow filters to reduce the design complexity.