Break down the task into parts and assign each part a time
Work in units of not less than 1/2 a day. This will prevent micro-scheduling
The big problem with project estimation is underestimation. If you know the task well and can almost see the code then weight the task by 1. If there is some uncertainty or the task requires an unknown technology then multiply it by a higher factor, depending on the level of uncertainty
Don't worry too much about accuracy of each part. The errors tend to cancel out as the only thing that really matters is the total duration
There is always the good old standby of taking the optimistic time scale and multiplying it by PI. Works more often than it should!