Brian Abraham's reply is absolutely correct, but he forgot to allow for Nutation. That should make the formulae valid for only the next 200 years or so, you'd better re-write the programme after that
In the programmes that I've written I've always used 'Half Sun' to 'Half Sun' as a slightly conservative approach for aviation, but if you're writing a programme for Ramadan, you'd better apply 'Upper limb' to 'Upper limb'.
Happy Ramadan and Regards,
Old Smokey