How does an iOS device keep time when it is out of power? My iPhone is always running out of battery.  However, when I power it back up, the time is still in perfect synchronization.  This begs the question: "How does it keep time when it is out of battery?"

There must be some sort of 'ticking' mechanism in the phone while it is out of battery and, thus, not entirely out of battery.
The iPhone is not completely depleted when the battery "dies."  If you'll notice, when you try to turn it on when the battery is dead, the screen will come on briefly to tell you the battery is dead -- i.e., there is still some energy left in the battery.  The clock continues to run off of the battery, and takes such a small amount of energy that Apple decided to keep the clock going.

Eventually, the battery will completely die (probably after many days or weeks), and the clock will eventually stop keeping time.  As Ian C. mentioned, the clock will synchronize when the phone does get plugged in and turned on again, if a network is available.