Recounts and legal challenges can take months to play out in some cases, but not in the election of a president: the Constitution sets strict deadlines, and not just the date for the inauguration.
There have been some long fights for office elsewhere. When Norm Coleman of Minnesota ran for the U.S. Senate in 2008, the election night count showed him beating Al Franken by a mere 725 votes. That triggered a process of recounts and court battles that played out for eight months. Al Franken wasn’t sworn in until July 2009.
In Washington state, Dino Rossi gave up fighting seven months after it appeared he’d been elected governor in 2004 by a margin of 261 votes, when a third recount declared Christine Gregoire the winner.