Weak solutions to non-homogeneous boundary value problems for time-fractional diffusion equations