X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Futil.h;h=0db903e4679105471a94e64599b521b140b719ce;hp=632ba0e6d8aa2d9121634d20eb11ab50e6cba57c;hb=ce250a863bce3198096e65d4c7a68269495302dd;hpb=68878dc8366f2f4a0afe132847aad9a51a80cdbf diff --git a/src/common/util.h b/src/common/util.h index 632ba0e6..0db903e4 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -79,3 +79,27 @@ QByteArray prettyDigest(const QByteArray &digest); * @return String with current date/time substituted in via formatting codes */ QString formatCurrentDateTimeInString(const QString &formatStr); + +/** + * Try to localize a given date/time in seconds from Unix epoch, pass through string if invalid + * + * Allows compatibility with date/time fields that may or may not be in Unix epoch format, + * localizing if possible, leaving alone if not. + * + * @param possibleEpochDate Date/time that might be in seconds since Unix epoch format + * @param dateFormat Desired format of the date/time string + * @param useUTC If true, use UTC timezone, otherwise use local time + * @return Localized date/time if parse succeeded, otherwise the source string + */ +QString tryFormatUnixEpoch(const QString &possibleEpochDate, + Qt::DateFormat dateFormat = Qt::DateFormat::TextDate, + bool useUTC = false); + + +/** + * Format the given date/time in ISO 8601 format with timezone offset + * + * @param dateTime Date/time of interest + * @return Date/time in ISO 8601 format with timezone offset + */ +QString formatDateTimeToOffsetISO(const QDateTime &dateTime);