This a vast question. You need to be more specific: Where? What is your application? What kind of data (hourly, daily, monthly) and for how long? What accuracy do you need? What is your budget? etc.
You need some astronomy knowledge, especially how to calculate the day duration in a given locality. You must also utilized some weather model for describing your locality.