OGS
GetDateTime.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <QDateTime>
7#include <QString>
8#include <string>
9
11inline QDateTime getDateTime(QString const& stringDate)
12{
13 if (stringDate.length() == 10)
14 return QDateTime::fromString(stringDate, "dd.MM.yyyy");
15
16 if (stringDate.length() == 19)
17 return QDateTime::fromString(stringDate, "dd.MM.yyyy.HH.mm.ss");
18
19 return QDateTime();
20}
21
23inline QDateTime getDateTime(std::string const& stringDate)
24{
25 return getDateTime(QString::fromStdString(stringDate));
26}
QDateTime getDateTime(QString const &stringDate)
Converts string into QDateTime-format.
Definition GetDateTime.h:11