in reply to unix timestamp

Actually, you can use mktime. Weekday is there because the arguments correspond to the "struct tm" structure. The same struct is used for both input and output, but on input to mktime, "the original values of the tm_wday and tm_yday components of the structure are ignored". See the Posix definition of mktime.