We know that a function must satisfy Dirichlet's Conditions before it can be expanded in Fourier series. And Dirichlet's Conditions strictly require a function to be periodic in the interval in which it is to be expanded. But $f(x)=x^2$ is not periodic in any real interval $[-l,+l]$.
Then why and how can we calculate the Fourier series of $f(x)=x^2$ in any interval $[-l,+l]$?