Ok, coming from an un-experienced never really flown future pilot who has been reading his textbook and knows a little about electricity and engines...
As said above, your engine doesn't need the battery/alternator to keep going. So what you're really worried about is your instruments, radio, and lights.
I wouldn't trust my life to any battery if I could avoid it. So I'd point the airplane towards the airport I need to go to, then kill everything I didn't absolutely need until it was time to land- probably even hit the master switch if there was nowhere nearby to land. Then bring it all back up in time to approach the airport.
If you only turned on the instruments when you really needed to... say periodically to get a navigational fix and right before your approach/landing you could probably milk a couple hours of everything.
It has happened to us twice.
The first time our electrical system went away, we were brand-new pilots on our first outing away from known territory. We considered it an emergency and landed at the nearest airport despite the fact that they had no facilities and was unattended. Fortunately, a pilot landed shortly afterward who found us a mechanic and gave us a ride to and from a local hotel. Pilots are wonderful people.
By the time it happened the second time, we had flown across the country a few times and were much more comfortable with the capabilities of ourselves and the plane. So, the alternator failed while we were somewhere between New York and Oshkosh. I had the sectional open and immediately knew where we were and in a moment, knew where the nearest towered airport was, and how to get there using pilotage. We radioed the tower with, "We are 50 miles east and lost electrical power." He immediately gave us the weather and cleared us to land and cleared us to taxi and told us there was no need for further radio communication. We turned off the avionics master and kept flying until we landed there. Eventually, we hand-propped and flew to an airport where we could get a new alternator.
Notes on electrical failure:
1. You can fly without a battery until the fuel runs dry.
2. Do not hand-prop unless you have been trained to do it. Hand-propping is very dangerous.
3. Always know where you are and how to get to a good airport.
4. If safe, land at an airport that can service your plane.
5. Tower controllers are your friend. Pilots are, too.