https://linuxjm.osdn.jp/html/LDP_man-pages/man3/ctime.3.html
localtime_r()を使いましょう

struct tm *tm1 = localtime(&now);
こんな使い方をするって時点でlocaltime()が「何」を返すのか、察しましょう