OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches

DateTime utility functions — numerically identical to legacy datetime.c. More...

#include <cmath>
Include dependency graph for DateTime.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  openswmm
 
namespace  openswmm::datetime
 

Typedefs

using openswmm::datetime::DateTime = double
 

Functions

void openswmm::datetime::divMod (int n, int d, int *result, int *remainder)
 Integer divmod — matching legacy divMod().
 
bool openswmm::datetime::isLeapYear (int year)
 Check if year is a leap year.
 
DateTime openswmm::datetime::encodeDate (int year, int month, int day)
 Encode year-month-day to DateTime.
 
DateTime openswmm::datetime::encodeTime (int hour, int minute, int second)
 Encode hour:minute:second to fractional day.
 
void openswmm::datetime::decodeDate (DateTime date, int &year, int &month, int &day)
 Decode DateTime to year-month-day.
 
void openswmm::datetime::decodeTime (DateTime time, int &h, int &m, int &s)
 Decode DateTime to hour:minute:second.
 
DateTime openswmm::datetime::addSeconds (DateTime date, double seconds)
 Add seconds to a DateTime — numerically identical to legacy.
 
long openswmm::datetime::timeDiff (DateTime date1, DateTime date2)
 Compute difference in seconds between two DateTimes.
 
int openswmm::datetime::monthOfYear (DateTime date)
 Get month of year (1..12) from DateTime.
 
int openswmm::datetime::dayOfYear (DateTime date)
 Get day of year (1..365/366) from DateTime.
 

Detailed Description

DateTime utility functions — numerically identical to legacy datetime.c.

Replicates the exact date/time encoding, decoding, and arithmetic from the legacy SWMM datetime.c. Uses the same DateDelta epoch (days from 01/01/0000 to 12/31/1899), the same integer H:M:S decomposition, and the same rounding behavior.

This ensures that operations like datetime_addSeconds() produce bit-identical results to the legacy engine, which is critical for deterministic rain gage interval boundary alignment.

See also
Legacy reference: src/legacy/engine/datetime.c
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License