18#include "kanoopcommon.h"
36 QDateTime result = QDateTime::fromString(date, Qt::DateFormat::ISODateWithMs);
37 result.setTimeZone(QTimeZone::utc());
77 return milliseconds ? date.toString(
"yyyy-MM-dd hh:mm:ss.zzz") : date.toString(
"yyyy-MM-dd hh:mm:ss");
85 static QString
toISOString(
const QDateTime& date) {
return date.toString(
"yyyy-MM-ddThh:mm:ss.zzzZ"); }
92 static QString
toSquashedString(
const QDateTime& date) {
return date.toString(
"yyyyMMddhhmmsszzz"); }
99 static QString
toStandardTimeString(
const QDateTime& date) {
return date.time().toString(
"HH:mm:ss.zzz"); }
112 static QString
currentToISOString() {
return QDateTime::currentDateTimeUtc().toString(
"yyyy-MM-ddThh:mm:ss.zzzZ"); }
121 return milliseconds ? QDateTime::currentDateTimeUtc().toString(
"yyyy-MM-dd hh:mm:ss.zzz") : QDateTime::currentDateTimeUtc().toString(
"yyyy-MM-dd hh:mm:ss");
136 static QDateTime fromAlternate1String(
const QString& date)
138 QDateTime result = QDateTime::fromString(date,
"yyyy-MM-dd dddd hh:mm:ss.zzz");
139 result.setTimeZone(QTimeZone::utc());
142 static QDateTime fromGitRepresentation(
const QString& date)
144 QDateTime dateTime = QDateTime::fromString(date,
"ddd MMM d hh:mm:ss yyyy tt").toUTC();
static QString currentToSquashedString()
Return the current UTC time as a compact squashed string.
static QString toStandardString(const QDateTime &date, bool milliseconds=true)
Format a QDateTime as a MySQL-style string.
static QString toStandardTimeString(const QDateTime &date)
Format the time portion of a QDateTime as "HH:mm:ss.zzz".
static QDateTime fromStandardString(const QString &date)
Parse a MySQL-style "yyyy-MM-dd hh:mm:ss.zzz" string into a QDateTime.
static QString currentToStandardString(bool milliseconds=true)
Return the current UTC time as a MySQL-style string.
static QDateTime fromISOString(const QString &date)
Parse an ISO-8601 string into a UTC QDateTime.
static QString toSquashedString(const QDateTime &date)
Format a QDateTime as a compact squashed string.
static QString toStandardDateString(const QDateTime &date)
Format the date portion of a QDateTime as "yyyy-MM-dd".
static QDateTime fromString(const QString &date)
Parse a date/time string, trying multiple known formats.
static QDateTime fromVariant(const QVariant &date)
Parse a QVariant containing a date/time string or QDateTime.
static QDateTime fromSquashedString(const QString &date)
Parse a compact "yyyyMMddhhmmsszzz" string into a QDateTime.
static QString toISOString(const QDateTime &date)
Format a QDateTime as an ISO-8601 Zulu string.
static QString currentToISOString()
Return the current UTC time as an ISO-8601 Zulu string.