<s> import datetime <EOL> import time <EOL> class CountdownManager ( object ) : <EOL> def __init__ ( self , root_tk_app ) : <EOL> self . start_time = time . time ( ) <EOL> self . minutes = <NUM_LIT:0> <EOL> self . seconds = <NUM_LIT:0> <EOL> self . time_change_callbacks = [ ] <EOL> self . count_down_total = datetime . timedelta ( days = - <NUM_LIT:1> , minutes = <NUM_LIT:0> , seconds = <NUM_LIT:0> ) <EOL> self . root_tk_app = root_tk_app <EOL> self . refresh_timer ( ) <EOL> def set_countdown_duration ( self , minutes , seconds ) : <EOL> self . start_time = time . time ( ) <EOL> self . minutes = minutes <EOL> self . seconds = seconds <EOL> self . count_down_total = datetime . timedelta ( minutes = minutes , seconds = seconds ) <EOL> self . fire_time_change_callbacks ( ) <EOL> def subscribe_to_time_changes ( self , time_change_callback ) : <EOL> self . time_change_callbacks . append ( time_change_callback ) <EOL> def fire_time_change_callbacks ( self ) : <EOL> end_time = time . time ( ) <EOL> up_time = end_time - self . start_time <EOL> remaining_time = self . count_down_total - datetime . timedelta ( seconds = ( int ( up_time ) ) ) <EOL> for callback in self . time_change_callbacks : <EOL> if callback : <EOL> callback ( remaining_time . days , ( remaining_time . seconds // <NUM_LIT> ) % <NUM_LIT> , remaining_time . seconds % <NUM_LIT> ) <EOL> def refresh_timer ( self ) : <EOL> self . fire_time_change_callbacks ( ) <EOL> if self . root_tk_app : <EOL> self . root_tk_app . after ( <NUM_LIT> , self . refresh_timer ) </s>
