int ExtDate::daysInMonth() const
{
- int a_month = month();
- return (a_month == 2) ? (leapYear(year()) ? 29 : 28) : m_monthLength[a_month-1] ;
+ if ( isValid() ) {
+ int m = month();
+ int d = m_monthLength[m-1];
+ if (m==2 && leapYear(year())) d++;
+ return d;
+ } else {
+ return 31;
+ }
}
int ExtDate::daysInYear() const
{
+ if ( ! isValid() ) return 365;
return (leapYear(year()) ? 366 : 365);
}
public:
/**
- * Constructs a date selection widget.
+ * Constructs a date selection widget, initialized to the current CPU date.
*/
ExtDateWidget( QWidget *parent=0, const char *name=0 );
#include <kdatepicker.h>
+#include <kdatewidget.h>
#include <klineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include "extdatepicker.h"
+#include "extdatewidget.h"
#include "testwidget.h"
TestWidget::TestWidget( QWidget *p=0, const char *name=0 ) : KMainWindow( p, name ) {
edpEdit = new KLineEdit(w);
edpEdit->setReadOnly( TRUE );
+ kdw = new KDateWidget( QDate::currentDate(), w );
+ edw = new ExtDateWidget( ExtDate::currentDate(), w );
+
glay->addWidget( kdpLabel, 0, 0 );
glay->addWidget( edpLabel, 0, 1 );
glay->addWidget( kdp, 1, 0 );
glay->addWidget( edp, 1, 1 );
glay->addWidget( kdpEdit, 2, 0 );
glay->addWidget( edpEdit, 2, 1 );
+ glay->addWidget( kdw, 3, 0 );
+ glay->addWidget( edw, 3, 1 );
setCentralWidget(w);