Warning, /sdk/clazy/docs/checks/README-qdatetime-utc.md is written in an unsupported language. File is not indexed.

0001 # qdatetime-utc
0002 
0003 Finds cases where less expensive QDateTime code paths can be used for getting the milliseconds/seconds since epoch.
0004 This includes `QDateTime::currentDateTime().toUTC()` which should be replaced by `QDateTime::currentDateTimeUTC`()` to avoid expensive timezone code paths.
0005 Getting the UTC datetime directly instead of resolving the current datetime is around 99% faster. In case the milliseconds/seconds since epoch are used,
0006 the direct static accessors for those values halve the already improved time again.
0007 
0008 ## Examples:
0009 ```cpp
0010 QDateTime::currentDateTime().toUTC()
0011 QDateTime::currentDateTime().toTime_t() // Qt5 only
0012 QDateTime::currentDateTime().toMSecsSinceEpoch()
0013 QDateTime::currentDateTimeUtc().toMSecsSinceEpoch();
0014 QDateTime::currentDateTime().toSecsSinceEpoch();
0015 QDateTime::currentDateTimeUtc().toSecsSinceEpoch();
0016 ```
0017 ## Fixits
0018 
0019 ```
0020 main.cpp:7:5: warning: Use QDateTime::currentDateTimeUtc() instead. It is significantly faster [-Wclazy-qdatetime-utc]
0021     QDateTime::currentDateTime().toUTC();
0022     ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
0023              ::currentDateTimeUtc()
0024 
0025 main.cpp:12:5: warning: Use QDateTime::currentMSecsSinceEpoch() instead. It is significantly faster [-Wclazy-qdatetime-utc]
0026     QDateTime::currentDateTimeUtc().toMSecsSinceEpoch();
0027     ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0028              ::currentMSecsSinceEpoch()
0029 main.cpp:14:5: warning: Use QDateTime::currentSecsSinceEpoch() instead. It is significantly faster [-Wclazy-qdatetime-utc]
0030     QDateTime::currentDateTimeUtc().toSecsSinceEpoch();
0031     ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0032              ::currentSecsSinceEpoch()
0033 ```