Depends on if you're going to use it as a base-camp to explore some of the surrounding area. Give yourself the day of arrival, a whole day to explore the city, a day to take a trip up to the pass, a day to explore some of the temples in the surrounding area. That's four nights. I rather liked the laid back nature of the town within the wall, it has a very different feel from Da Nang and Hoi'an.
Main attractions in Hue are the Citadel and Tombs which can be seen in 1 long day or 2 part days. Can do a DMZ tour but not sure they are really worth it from what I have read, if interested in war maybe just go to the tunnels instead as they seem to be the main thing worth seeing.
I would say 3 days probably max imo is what I would spend there, I did it in 2 days myself and would probably do the same if I went back again.
Why are you trying to figure this out now? My advice would be not to attach a timeline to your itinerary. Leave when the place no longer interests you. If you are enjoying it, stay until you don't or you run out of time. Don't overplan.
Madmac is right. Keep it as flexible as you can as your plans will change.
Four days in Hue is good if you've got the time up your sleeve - it really depends on the rest off your itinerary and your total travel time. If you're on a tight schedule, then cut it down to 2-3 full days. If you're on a really tight schedule, I'd suggest leaving it in favour of other parts of Vietnam. One of the things I enjoyed doing in Hue was an all-day motorbike trip across the DMZ to the Vinh Moc tunnels. I hired a motorbike driver through my guesthouse (I wasn't game to drive myself in Vietnam at that point!). He made various stops along the way, through rice fields, temples, the tunnels, various other historical places of interest. It was a long day - but fun and interesting. The tunnels are esp worth a visit.