Try and simplify the #includes, include <time.h> for localtime.