28#ifndef OPENSWMMVIS_CORE_SWMMDATETIME_H
29#define OPENSWMMVIS_CORE_SWMMDATETIME_H
33#include <openswmm/engine/openswmm_datetime.h>
51 if (!std::isfinite(value))
54 int y = 0, mo = 0, d = 0,
h = 0, mi = 0,
s = 0;
55 swmm_datetime_decode_date(value, &y, &mo, &d);
56 swmm_datetime_decode_time(value, &
h, &mi, &
s);
58 const QDate date(y, mo, d);
61 return QDateTime(date, QTime(
h, mi,
s), Qt::UTC);
73 return std::numeric_limits<double>::quiet_NaN();
75 const QDate d = dt.date();
76 const QTime
t = dt.time();
78 double datePart = 0.0;
79 swmm_datetime_encode_date(d.year(), d.month(), d.day(), &datePart);
84 const long secOfDay = std::lround(
85 (
t.hour() * 3600 +
t.minute() * 60 +
t.second()) +
t.msec() / 1000.0);
86 const int clamped =
static_cast<int>(secOfDay >= 86400 ? 86399 : secOfDay);
88 double timePart = 0.0;
89 swmm_datetime_encode_time(clamped / 3600, (clamped % 3600) / 60, clamped % 60,
91 return datePart + timePart;
DiagramType t
Definition diagramspec.cpp:20
double s
Scene px per model length unit.
Definition inletdrawingview.cpp:82
int h
Definition mesh2dresultsexport.cpp:387
Definition swmmdatetime.h:42
double qDateTimeToSwmmDateTime(const QDateTime &dt)
QDateTime → SWMM DateTime double.
Definition swmmdatetime.h:70
QDateTime swmmDateTimeToQDateTime(double value)
SWMM DateTime double → UTC-labelled QDateTime (wall clock).
Definition swmmdatetime.h:49