32#include "datechecker.h"
34DateChecker::DateChecker( TQObject *parent,
const char *name )
35 : TQObject( parent, name ), mUpdateTimer( 0 )
37 enableRollover( FollowMonth );
40DateChecker::~DateChecker()
44void DateChecker::enableRollover( RolloverType r )
56 if ( !mUpdateTimer ) {
57 mUpdateTimer =
new TQTimer(
this,
"mUpdateTimer" );
58 connect( mUpdateTimer, TQ_SIGNAL( timeout() ),
59 TQ_SLOT( possiblyPastMidnight() ) );
61 mUpdateTimer->start( 0,
true );
62 mLastDayChecked = TQDate::currentDate();
67void DateChecker::passedMidnight()
69 TQDate today = TQDate::currentDate();
71 if ( today.month() != mLastDayChecked.month() ) {
72 if ( mUpdateRollover == FollowMonth ) {
73 emit monthPassed( today );
76 emit dayPassed( today );
79void DateChecker::possiblyPastMidnight()
81 if ( mLastDayChecked != TQDate::currentDate() ) {
83 mLastDayChecked = TQDate::currentDate();
88 TQTime now = TQTime::currentTime();
89 TQTime midnight = TQTime( 23, 59, 59 );
90 int msecsWait = TQMIN( 480000, now.msecsTo( midnight ) + 2000 );
93 mUpdateTimer->start( msecsWait,
true );
97#include "datechecker.moc"