SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
swmmdatetime.h File Reference

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>
Include dependency graph for swmmdatetime.h:
This graph shows which files directly or indirectly include this file:

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.
 

Detailed Description

Canonical SWMM DateTime <-> QDateTime conversion for the GUI.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
Date
2026
License\n GPL-3.0-or-later

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.