Yes, the block should be generated every 10 minutes but it is not. I want to build next difficulty prediction based on time value that will be required to generate next 2016 blocks after difficulty change. I want to extrapolate current block count into future and estimate this time.
Parse the blockchain and get a timestamp of each block from that you'll know how much time was needed to solve the last 2016 blocks.
It will still be a guesstimate if you just divide the time it took to solve last 2016 blocks by 20,160 minutes and multiply that ratio by the current hashrate.
The problem with estimates is that hash rate does not follow exactly what you would expect, i.e. 10 minutes per block. Some big farms come online, or go down for maintenance and this affects the times.