|
| SWMM_ENGINE_API int | swmm_datetime_encode_date (int year, int month, int day, double *out) |
| | Encode a calendar date as a SWMM DateTime (date portion only).
|
| |
| SWMM_ENGINE_API int | swmm_datetime_encode_time (int hour, int minute, int second, double *out) |
| | Encode a wall-clock time as the fractional-day part of a SWMM DateTime.
|
| |
| SWMM_ENGINE_API int | swmm_datetime_decode_date (double value, int *year, int *month, int *day) |
| | Decode the date portion of a SWMM DateTime.
|
| |
| SWMM_ENGINE_API int | swmm_datetime_decode_time (double value, int *hour, int *minute, int *second) |
| | Decode the time-of-day portion of a SWMM DateTime.
|
| |
| SWMM_ENGINE_API int | swmm_datetime_add_seconds (double value, double seconds, double *out) |
| | Add a (possibly fractional) number of seconds to a SWMM DateTime.
|
| |
| SWMM_ENGINE_API int | swmm_datetime_time_diff (double value1, double value2, long *out) |
| | Compute the difference, in whole seconds, between two SWMM DateTimes.
|
| |
OpenSWMM Engine — SWMM DateTime conversion utilities (C API).
SWMM's native DateTime is a double. The integer part is the number of days since 1899-12-30 (the OLE Automation / Delphi TDateTime epoch) and the fractional part is the time-of-day fraction (0.0 = midnight, 0.5 = noon). This is the same representation produced and consumed by every other date or time value crossing the C API boundary — for example swmm_options_get_start_date, swmm_get_current_time, swmm_output_get_period_time and the sim_time argument passed to engine callbacks.
This header exposes the encode/decode primitives used inside the engine so language bindings (Python, .NET, etc.) can convert losslessly between the SWMM DateTime double and their native calendar/time types without re-implementing the epoch arithmetic.
The functions are pure (no engine handle required) and numerically identical to the legacy datetime.c routines.
- Note
- This is NOT an astronomical Julian Date. The epoch is 1899-12-30, matching Microsoft's OLE Automation date and Delphi's TDateTime — the format SWMM has always used.
Usage
double d, t, sim_t;
sim_t = d + t;
double * y
Definition odesolve.c:28
OpenSWMM Engine — SWMM DateTime conversion utilities (C API).
SWMM_ENGINE_API int swmm_datetime_encode_time(int hour, int minute, int second, double *out)
Encode a wall-clock time as the fractional-day part of a SWMM DateTime.
Definition openswmm_datetime_impl.cpp:30
SWMM_ENGINE_API int swmm_datetime_decode_date(double value, int *year, int *month, int *day)
Decode the date portion of a SWMM DateTime.
Definition openswmm_datetime_impl.cpp:41
SWMM_ENGINE_API int swmm_datetime_encode_date(int year, int month, int day, double *out)
Encode a calendar date as a SWMM DateTime (date portion only).
Definition openswmm_datetime_impl.cpp:22
SWMM_ENGINE_API int swmm_datetime_decode_time(double value, int *hour, int *minute, int *second)
Decode the time-of-day portion of a SWMM DateTime.
Definition openswmm_datetime_impl.cpp:52
- Author
- Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
- Copyright
- Copyright (c) 2026 Caleb Buahin. All rights reserved.
- License\n MIT License