if (epoch % 86400L) is the time of day, (epoch / 86400L) is the number of days since epoch:
long day = epoch / 86400L;
Since there are 7 days a week:
int day_of_the_week = day % 7;
Since January 1, 1970 was a Thursday the results are:
0=Thursday
1=Friday
2=Saturday
3=Sunday
4=Monday
5=Tuesday
6=Wednesday
If you want 0 to be Sunday, use "(day+4) % 7" instead.