Skip to content

Commit

Permalink
Set the minimum datetime widget value to 1 CE instead of 100 CE
Browse files Browse the repository at this point in the history
The lower limit was set to Jan 1st 100 CE only because QDateTimeEdit::setMinimumDateTime doesn't support dates < '0100-01-01'.
This limitation doesn't affect QDateTimeEdit::setDateTimeRange so it is possible to allow entering dates also from 1 CE to 99 CE which previously where not allowed.
  • Loading branch information
agiudiceandrea authored and nyalldawson committed May 28, 2020
1 parent d2f72e8 commit f86f476
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/gui/editorwidgets/qgsdatetimeedit.h
Expand Up @@ -188,19 +188,17 @@ class GUI_EXPORT QgsDateTimeEdit : public QDateTimeEdit
void resetBeforeChange( int delta );

/**
* Set the lowest Date that can be displayed with the Qt::ISODate format
* - uses QDateTimeEdit::setMinimumDateTime (since Qt 4.4)
* Set the lowest Date that can be stored in a Shapefile or Geopackage Date field
* - uses QDateTimeEdit::setDateTimeRange (since Qt 4.4)
* \note
* - QDate and QDateTime does not support minus years for the Qt::ISODate format
* -> returns empty (toString) or invalid (fromString) values
* - QDateTimeEdit::setMinimumDateTime does not support dates < '0100-01-01'
* -> it is not for us to wonder why [defined in qdatetimeparser_p.h]
* \note not available in Python bindings
* \since QGIS 3.0
*/
void setMinimumEditDateTime()
{
setMinimumDateTime( QDateTime::fromString( QStringLiteral( "0100-01-01" ), Qt::ISODate ) );
setDateTimeRange( QDateTime( QDate( 1, 1, 1 ) ), maximumDateTime() );
}

friend class TestQgsDateTimeEdit;
Expand Down

0 comments on commit f86f476

Please sign in to comment.