OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_datetime.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
67
68#ifndef OPENSWMM_ENGINE_DATETIME_H
69#define OPENSWMM_ENGINE_DATETIME_H
70
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77/* =========================================================================
78 * Epoch constant
79 * ========================================================================= */
80
88#define SWMM_DATETIME_DATE_DELTA 693594
89
90/* =========================================================================
91 * Encode (calendar parts -> SWMM DateTime double)
92 * ========================================================================= */
93
106SWMM_ENGINE_API int swmm_datetime_encode_date(int year, int month, int day,
107 double* out);
108
121SWMM_ENGINE_API int swmm_datetime_encode_time(int hour, int minute, int second,
122 double* out);
123
124/* =========================================================================
125 * Decode (SWMM DateTime double -> calendar parts)
126 * ========================================================================= */
127
139 int* year, int* month, int* day);
140
156 int* hour, int* minute, int* second);
157
158/* =========================================================================
159 * DateTime arithmetic
160 * ========================================================================= */
161
175SWMM_ENGINE_API int swmm_datetime_add_seconds(double value, double seconds,
176 double* out);
177
187SWMM_ENGINE_API int swmm_datetime_time_diff(double value1, double value2,
188 long* out);
189
190#ifdef __cplusplus
191} /* extern "C" */
192#endif
193
194#endif /* OPENSWMM_ENGINE_DATETIME_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
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:46
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:57
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:38
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.
Definition openswmm_datetime_impl.cpp:79
SWMM_ENGINE_API int swmm_datetime_time_diff(double value1, double value2, long *out)
Compute the difference, in whole seconds, between two SWMM DateTimes.
Definition openswmm_datetime_impl.cpp:86
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:68