My guess is that it's a bad battery again, but that's just a guess. It's not uncommon for OEM batteries to only last 2 years or so, especially if you're putting a lot of draw on the electrical system (aftermarket radio/amplifiers, lighting, etc). They typically start to show their age and problems right around this time of year, when it starts to get colder overnight and in the mornings when you try and start your vehicle. My Xterra had a brand new OEM battery when I purchased it as a "certified" used car with 33,000 miles. It lasted me a year (until about 45,000 miles), and I then swapped it out with an Interstate battery from Costco. I installed my second battery mod, which put a much harder strain on the charging system, and the Costco battery lasted me about 2 years. Costco gave me a full refund, since it had a 4 year warranty. I then purchased an Odyssey battery from 4 Wheel Parts and haven't had any issues since.
The weird code and issue with your gauges could have just come from the voltage dropping so low while the vehicle was trying to start. That can play all kinds of tricks on your computers and sensors. I've never heard of that specifically on an Xterra, but I have seen vehicles do weird things like this with just a bad battery. You said the battery was swapped out at 30k under warranty, but how many years ago was that? I'd highly recommend trying a better, aftermarket battery and seeing if that fixes the issues.