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
90#define SWMM_DATETIME_DATE_DELTA 693594
91
92/* =========================================================================
93 * Encode (calendar parts -> SWMM DateTime double)
94 * ========================================================================= */
95
108SWMM_ENGINE_API int swmm_datetime_encode_date(int year, int month, int day, double* out);
109
123SWMM_ENGINE_API int swmm_datetime_encode_time(int hour, int minute, int second, double* out);
124
125/* =========================================================================
126 * Decode (SWMM DateTime double -> calendar parts)
127 * ========================================================================= */
128
140SWMM_ENGINE_API int swmm_datetime_decode_date(double value, int* year, int* month, int* day);
141
157SWMM_ENGINE_API int swmm_datetime_decode_time(double value, int* hour, int* minute, int* second);
158
159/* =========================================================================
160 * DateTime arithmetic
161 * ========================================================================= */
162
176SWMM_ENGINE_API int swmm_datetime_add_seconds(double value, double seconds, double* out);
177
189SWMM_ENGINE_API int swmm_datetime_time_diff(double value1, double value2, long* out);
190
191#ifdef __cplusplus
192} /* extern "C" */
193#endif
194
195#endif /* OPENSWMM_ENGINE_DATETIME_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
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:48
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:60
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:39
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:90
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:98
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:75
Build-generated visibility and deprecation macros for the engine API.