Skip to content

Commit

Permalink
WMS/WMTS provider: support 'yyyy' TIME format
Browse files Browse the repository at this point in the history
Fixes #60264
  • Loading branch information
rouault authored and github-actions[bot] committed Jan 28, 2025
1 parent ccd674a commit d2ef1bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,12 @@ QDateTime QgsWmsSettings::parseWmstDateTimes( const QString &item )

// Check if it does not have time part
if ( !item.contains( 'T' ) )
return QDateTime::fromString( item, QStringLiteral( "yyyy-MM-dd" ) );
{
if ( item.size() == 4 )
return QDateTime::fromString( item, QStringLiteral( "yyyy" ) );
else
return QDateTime::fromString( item, QStringLiteral( "yyyy-MM-dd" ) );
}
else if ( item.contains( '.' ) )
return QDateTime::fromString( item, Qt::ISODateWithMs );
else
Expand Down
2 changes: 1 addition & 1 deletion tests/src/providers/testqgswmscapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TestQgsWmsCapabilities : public QObject
{
QgsWmsSettings settings = QgsWmsSettings();

QMap<QString, QString> map = { { "2020-02-13T12:00:00Z", "yyyy-MM-ddThh:mm:ssZ" }, { "2020-02-13", "yyyy-MM-dd" } };
QMap<QString, QString> map = { { "2020-02-13T12:00:00Z", "yyyy-MM-ddThh:mm:ssZ" }, { "2020-02-13", "yyyy-MM-dd" }, { "2020", "yyyy" } };
QMapIterator<QString, QString> iterator( map );

while ( iterator.hasNext() )
Expand Down

0 comments on commit d2ef1bf

Please sign in to comment.