Example #1
0
void Clock::display(tm *currentTime){

     int hour = currentTime->tm_hour;
     bool isPm = 0;

     if( hour>=12 )
         isPm = 1;
     else 
         isPm = 0;

     // military time to 12 hour time
     if(!militaryTime){
         if(hour>12)
             hour -= 12;
         else if(hour == 0)
             hour = 12;
     }
     
     int hourTens = hour/10;
     int hourOnes = hour%10;
     int minuteTens = ((currentTime->tm_min))/10;
     int minuteOnes = ((currentTime->tm_min))%10;
     int secondTens = ((currentTime->tm_sec))/10;
     int secondOnes = ((currentTime->tm_sec))%10;
     
     hour1.display( hourTens );
     hour2.display( hourOnes );
     minute1.display( minuteTens );
     minute2.display( minuteOnes );
     
     if(showSeconds && (mode != ALARM && mode != ALARM_SET)){
          second1.display( secondTens );
          second2.display( secondOnes );
          colon2( currentTime->tm_sec%2 );
          
     }
     else{
          second1.clear();
          second2.clear();
          colon2(0);
     }
          
     if( mode == ALARM || mode == ALARM_SET )
         colon(1);
     else
          colon( currentTime->tm_sec%2 );
          
     pm( isPm && !militaryTime );
     
     refresh();    
}
Example #2
0
void Clock::stopwatch()
{
        mvprintw(4, 80, "Setting stopwatch...");
        is24 = true;
        setClock();
        int input = 0;
        Colon colon1(5, 30), colon2(5, 55);
        bool oneSec = true;
        while((input = kbinput()) != 268 && !(hr == 0 && min == 0 && sec == 0))
        { 
            if(oneSec)
               lessSec(1); 
            oneSec = !oneSec;
            colon1.display(true);
            colon2.display(true);
            display(true);       
        }
        if(hr == 0 && min == 0 && sec == 0)
        {
            mvprintw(4, 80, "Time's up!!");
            for(int i = 0; i<7; i++)
                std::cout<<(char)7;
        }
        else
            mvprintw(4, 80, "Exiting timer");    
        clrtoeol();          
}
Example #3
0
void Clock::clear(){
    
    hour1.clear();
    hour2.clear();
    minute1.clear();
    minute2.clear();
    second1.clear();
    second2.clear();
    
    pm(0);
    colon(0);
    colon2(0);
     
}