Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int get_day(unsigned int timestamp)
- {
- time_t t = timestamp;
- struct tm * timeval = gmtime(&t);
- return timeval->tm_wday;//0 = sun
- }
- unsigned int get_start_of_day(unsigned int timestamp)
- {
- int day_of_w = get_day(timestamp);
- while(get_day(timestamp-3600) == day_of_w) timestamp -= 3600;
- while(get_day(timestamp-60) == day_of_w) timestamp -= 60;
- while(get_day(timestamp-1) == day_of_w) timestamp--;
- return timestamp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement