It's because you do the least constraint first:
if it's in the past then if less than 7 days then if less than 7 days
Firs toff, note the last two condition are identical. As far as I understand, the last one is there for the future ? If so, change your test sign and turn it to >
All this said, you should reverse ifses and end up with:
if in the future then // else if in the last past 7 days then // then // older than 7 days) end
Additional notes : — please, store the date in a local variable to make code lisible and less power hungry; — take now time first (for same reasons) plus, ech time you invoke getTime, the result changes by the time calls span in time (it's milliseconds, but…)