MythTV  master
Namespaces | Enumerations | Functions
mythdate.h File Reference
#include <cstdint>
#include <QDateTime>
#include <QString>
#include "mythbaseexp.h"
#include "mythchrono.h"
Include dependency graph for mythdate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 MythDate
 

Enumerations

enum  MythDate::Format {
  MythDate::ISODate = Qt::ISODate, MythDate::kFilename = 0x000100, MythDate::kDateFull = 0x000200, MythDate::kDateShort = 0x000400,
  MythDate::kDateEither = kDateFull | kDateShort, MythDate::kTime = 0x000800, MythDate::kDateTimeFull = kDateFull | kTime, MythDate::kDateTimeShort = kDateShort | kTime,
  MythDate::kAddYear = 0x001000, MythDate::kSimplify = 0x002000, MythDate::kDatabase = 0x004000, MythDate::kAutoYear = 0x008000,
  MythDate::kScreenShotFilename = 0x010000, MythDate::kRFC822 = 0x020000, MythDate::kOverrideUTC = 0x100000, MythDate::kOverrideLocal = 0x200000
}
 

Functions

QDateTime MythDate::current (bool stripped=false)
 Returns current Date and Time in UTC. More...
 
QString MythDate::current_iso_string (bool stripped=false)
 Returns current Date and Time in UTC as a string. More...
 
QDateTime MythDate::as_utc (const QDateTime &dt)
 Returns copy of QDateTime with TimeSpec set to UTC. More...
 
QDateTime MythDate::fromString (const QString &dtstr)
 Converts kFilename && kISODate formats to QDateTime. More...
 
MBASE_PUBLIC QDateTime MythDate::fromString (const QString &dt, const QString &format)
 Converts dy in format to QDateTime. More...
 
MBASE_PUBLIC QDateTime MythDate::fromSecsSinceEpoch (int64_t seconds)
 This function takes the number of seconds since the start of the epoch and returns a QDateTime with the equivalent value. More...
 
QString MythDate::toString (const QDateTime &datetime, uint format=MythDate::kDateTimeFull)
 Returns formatted string representing the time. More...
 
QString MythDate::toString (const QDate date, uint format)
 Returns a formatted QString based on the supplied QDate. More...
 
std::chrono::seconds MythDate::toSeconds (QTime time)
 Returns the total number of seconds since midnight of the supplied QTime. More...
 
std::chrono::milliseconds MythDate::currentMSecsSinceEpochAsDuration (void)
 
std::chrono::seconds MythDate::secsInPast (const QDateTime &past)
 
std::chrono::seconds MythDate::secsInFuture (const QDateTime &future)
 
QString MythDate::formatTime (std::chrono::milliseconds msecs, QString fmt)
 Format a milliseconds time value. More...
 
int ternary_compare (const QDateTime &a, const QDateTime &b)
 balanced ternary (three way) comparison This is equivalent to C++20's operator <=>. More...
 

Function Documentation

◆ ternary_compare()

int ternary_compare ( const QDateTime &  a,
const QDateTime &  b 
)
inline

balanced ternary (three way) comparison This is equivalent to C++20's operator <=>.

See also ternarycompare.h.

Less than means earlier and greater than means later.

Since Qt 5.14 invalid QDateTimes compare equal and are less than all valid QDateTimes.

Definition at line 76 of file mythdate.h.

Referenced by StringUtil::naturalCompare(), TitleSort::operator()(), ProgramRecPrioritySort::operator()(), ProgramRecTypeSort::operator()(), ProgramCountSort::operator()(), ProgramRecCountSort::operator()(), ProgramLastRecordSort::operator()(), ProgramAvgDelaySort::operator()(), and VideoMetadataImp::sortBefore().