OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
datetime.h
Go to the documentation of this file.
1
26
27#ifndef DATETIME_H
28#define DATETIME_H
29
34typedef double DateTime;
35
40#define Y_M_D 0
41
46#define M_D_Y 1
47
52#define D_M_Y 2
53
58#define NO_DATE -693594 // 1/1/0001
59
64#define DATE_STR_SIZE 12
65
70#define TIME_STR_SIZE 9
71
76#define TIME_STAMP_SIZE 21
77
85DateTime datetime_encodeDate(int year, int month, int day);
86
94DateTime datetime_encodeTime(int hour, int minute, int second);
95
103void datetime_decodeDate(DateTime date, int* year, int* month, int* day);
104
112void datetime_decodeTime(DateTime time, int* h, int* m, int* s);
113
120
127
134
141
148int datetime_daysPerMonth(int year, int month);
149
155void datetime_dateToStr(DateTime date, char* s);
156
162void datetime_timeToStr(DateTime time, char* s);
163
173void datetime_getTimeStamp(int fmt, DateTime aDate, int stampSize, char* timeStamp);
174
180int datetime_findMonth(char* month);
181
188int datetime_strToDate(char* s, DateTime* d);
189
196int datetime_strToTime(char* s, DateTime* t);
197
202void datetime_setDateFormat(int fmt);
203
210DateTime datetime_addSeconds(DateTime date1, double seconds);
211
219
226long datetime_timeDiff(DateTime date1, DateTime date2);
227
228#endif //DATETIME_H
void datetime_getTimeStamp(int fmt, DateTime aDate, int stampSize, char *timeStamp)
Format a calendar date and whole-second clock time in caller storage.
Definition datetime.c:675
void datetime_dateToStr(DateTime date, char *s)
Converts a DateTime value to a string.
Definition datetime.c:305
int datetime_monthOfYear(DateTime date)
Finds the month of the year for a date.
Definition datetime.c:563
int datetime_strToDate(char *s, DateTime *d)
Converts a string to a DateTime value.
Definition datetime.c:360
void datetime_decodeDate(DateTime date, int *year, int *month, int *day)
Decodes a DateTime value to year, month, and day.
Definition datetime.c:204
DateTime datetime_addDays(DateTime date1, DateTime date2)
Adds days to a DateTime value.
Definition datetime.c:505
DateTime datetime_encodeTime(int hour, int minute, int second)
Encodes a time value from hour, minute, and second to a DateTime value.
Definition datetime.c:174
int datetime_strToTime(char *s, DateTime *t)
Converts a string to a DateTime value.
Definition datetime.c:419
int datetime_dayOfYear(DateTime date)
Finds the day of the year for a date.
Definition datetime.c:584
double DateTime
Type for storing date and time values.
Definition datetime.h:34
int datetime_daysPerMonth(int year, int month)
Finds the number of days in a month.
Definition datetime.c:648
long datetime_timeDiff(DateTime date1, DateTime date2)
Finds the difference in seconds between two DateTime values.
Definition datetime.c:533
void datetime_decodeTime(DateTime time, int *h, int *m, int *s)
Decodes a DateTime value to hour, minute, and second.
Definition datetime.c:274
int datetime_hourOfDay(DateTime date)
Finds the hour of the day for a time.
Definition datetime.c:627
DateTime datetime_encodeDate(int year, int month, int day)
Encodes a date values from year, month, and day to a DateTime value.
Definition datetime.c:140
int datetime_findMonth(char *month)
Finds the month of the year for a date.
Definition datetime.c:114
DateTime datetime_addSeconds(DateTime date1, double seconds)
Adds seconds to a DateTime value.
Definition datetime.c:479
void datetime_setDateFormat(int fmt)
Sets the date format.
Definition datetime.c:458
void datetime_timeToStr(DateTime time, char *s)
Converts a DateTime value to a string.
Definition datetime.c:336
int datetime_dayOfWeek(DateTime date)
Finds the day of the week for a date.
Definition datetime.c:607