![]() |
SWMMVis
6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
|
Canonical SWMM DateTime <-> QDateTime conversion for the GUI. More...
#include "core/swmmdatetimeformat.h"#include <openswmm/engine/openswmm_datetime.h>#include <QDate>#include <QDateTime>#include <QTime>#include <cmath>#include <limits>Go to the source code of this file.
Namespaces | |
| namespace | openswmmvis |
| namespace | openswmmvis::core |
Functions | |
| QDateTime | openswmmvis::core::swmmDateTimeToQDateTime (double value) |
| SWMM DateTime double → UTC-labelled QDateTime (wall clock). | |
| double | openswmmvis::core::qDateTimeToSwmmDateTime (const QDateTime &dt) |
| QDateTime → SWMM DateTime double. | |
Canonical SWMM DateTime <-> QDateTime conversion for the GUI.
SWMM stores an absolute time as a single double: the integer part is the number of days since 1899-12-30 and the fractional part is the fraction of a 24-hour day. This is the OLE-Automation / Delphi TDateTime convention — it is not an astronomical Julian date.
These helpers delegate to the engine's own encode/decode primitives (openswmm/engine/openswmm_datetime.h) so every conversion is numerically identical to a SWMM run. In particular the decode side rounds the fractional day to the nearest second (floor(frac*86400 + 0.5), clamped to end-of-day) rather than truncating — which is what fixes the "00:15 shown as
00:14" defect (GH #1).
Time is treated as a timezone-naive wall clock. The QDateTime is labelled Qt::UTC purely so that no local-time / daylight-saving arithmetic is ever applied on the round-trip (GH #2). Never feed the results of these helpers through toLocalTime() / toUTC() for conversion purposes.
Header-only. Requires linking the engine target for the swmm_datetime_* symbols.