0

1: unsigned long normalise(unsigned long input_time)
2: {
3:
4: bool finished;
5:
6: // This produces a formatted time string like:
7: // Thu_Nov_24_18:22:48_1986
8: string str_time = format_time( input_time );
9:
10: while( str_time.substr(1,3) != "Sun")
11: {
12: input_time -= 24*60*60;
13: str_time = format_time( input_time );
14: }
15:
16: while( str_time.substr(11,2) != "00" )
17: {
18: input_time -= 60*60;
19: str_time = format_time( input_time );
20: }
21:
22: while( str_time.substr(14,2) != "00")
23: {
24: str_time = format_time( input_time );
25: input_time -= 60;
26: }
27:
28: while( str_time.substr(17,2) != "00")
29: {
30: input_time -= 1;
31: str_time = format_time( input_time );
32: }
33:
34: return input_time;
35: }

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by Hamrick
0

I have not written the function. I was asked this question by a friend which he had got in an interview. These days I am trying to solve as many questions as possible as I learn more from it. If the question is not clear then I can re-send it with exact words.

0

These days I am trying to solve as many questions as possible as I learn more from it.

If _you_ don't solve the question, what do you expect to learn? :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.