mtime 1.2.2
Loading...
Searching...
No Matches
mtime_calendar.h
Go to the documentation of this file.
1// Copyright (c) 2013-2024 MPI-M, Luis Kornblueh, Rahul Sinha and DWD, Florian Prill. All rights reserved.
2//
3// SPDX-License-Identifier: BSD-3-Clause
4//
35#ifndef _MTIME_CALENDAR_H
36#define _MTIME_CALENDAR_H
37
38extern const int NO_OF_SEC_IN_A_DAY;
39extern const int NO_OF_SEC_IN_A_HOUR;
40extern const int NO_OF_SEC_IN_A_MINUTE;
41
42extern const int NO_OF_MS_IN_A_DAY;
43extern const int NO_OF_MS_IN_HALF_DAY;
44extern const int NO_OF_MS_IN_A_HOUR;
45extern const int NO_OF_MS_IN_A_MINUTE;
46extern const int NO_OF_MS_IN_A_SECOND;
47
48/* #define NO_OF_SEC_IN_A_DAY 86400 */
49/* #define NO_OF_SEC_IN_A_HOUR 3600 */
50/* #define NO_OF_SEC_IN_A_MINUTE 60 */
51
52/* #define NO_OF_MS_IN_A_DAY 86400000 */
53/* #define NO_OF_MS_IN_HALF_DAY 43200000 */
54/* #define NO_OF_MS_IN_A_HOUR 3600000 */
55/* #define NO_OF_MS_IN_A_MINUTE 60000 */
56/* #define NO_OF_MS_IN_A_SECOND 1000 */
57
58#define NO_OF_DAYS_IN_A_MONTH_FOR_CAL_TYPE360 30
59
60#define NO_OF_MONTHS_IN_A_YEAR 12
61#define NO_OF_HOURS_IN_A_DAY 24
62
63#define NO_OF_DAYS_IN_A_YEAR_FOR_CAL_TYPE360 360
64#define NO_OF_DAYS_IN_A_YEAR_FOR_CAL_TYPE365 365
65#define NO_OF_DAYS_IN_A_LEAP_YEAR 366
66
67#define NO_OF_DAYS_IN_400_YEARS 146097
68
69#define YEAR_UPPER_BOUND 2147483647
70#define YEAR_LOWER_BOUND -2147483648
71
72#define POSIXSTRING_DAY_LOWER_BOUND 15
73#define POSIXSTRING_MONTH_LOWER_BOUND 10
74#define POSIXSTRING_YEAR_LOWER_BOUND 1582
75#define POSIXSTRING_YEAR_UPPER_BOUND 9999
76
78#define MAX_CALENDAR_STR_LEN 32
79#define MAX_DATETIME_STR_LEN 32
80#define MAX_DATE_STR_LEN 32
81#define MAX_TIME_STR_LEN 32
82#define MAX_TIMEDELTA_STR_LEN 32
83#define MAX_JULIANDAY_STR_LEN 32
84
85struct _datetime;
86struct _julianday;
87
88/* Used as dummy string to init TimeDeltas in the lib. */
89extern const char initDummyTDString[];
90extern const char initDummyDString[];
91extern const char initDummyDTString[];
92
93extern const int nofDaysAfterARGMonthsInLeapYear[13];
94extern const int nofDaysAfterARGMonthsInNonLeapYear[13];
95
96extern const int nofDaysInARGMonthInLeapYear[];
97extern const int nofDaysInARGMonthIn365DayYear[];
98extern const int nofDaysInARGMonthIn360DayYear[];
99
100extern const int monthSpecificDeltaInMonthsLeapyear[12][13];
101extern const int monthSpecificDeltaInMonths365[12][13];
102extern const int monthSpecificDeltaInMonths360[12][13];
103
104typedef enum
105{
106 equal_to = 0,
107 greater_than = 1,
108 less_than = -1,
109 compare_error = -128
110} compare_return_val;
111
126
128extern struct _julianday *(*date2julian)(struct _datetime *date, struct _julianday *julian);
129
131extern struct _datetime *(*julian2date)(struct _julianday *julian, struct _datetime *date);
132
134
135void freeCalendar(void);
136
138
139char *calendarToString(char *calendar);
140
144#endif
struct _date date
Date elements.
Definition mtime_datetime.h:37
calendarType
enum calendarType lists the calendarTypes supported. The values are used for selecting calendars.
Definition mtime_calendar.h:120
char * calendarToString(char *calendar)
convert the calendar identifier into a human readable string.
Definition mtime_calendar.c:188
void freeCalendar(void)
called to discard the selected calendar type.
Definition mtime_calendar.c:157
calendarType getCalendarType(void)
To query the current calendar type.
Definition mtime_calendar.c:173
void initCalendar(calendarType ct)
To initialize a new calendar.
Definition mtime_calendar.c:114
@ YEAR_OF_365_DAYS
365 day year without leap years.
Definition mtime_calendar.h:123
@ CALENDAR_NOT_SET
calendar is not defined yet.
Definition mtime_calendar.h:121
@ PROLEPTIC_GREGORIAN
proleptic Gregorian calendar.
Definition mtime_calendar.h:122
@ YEAR_OF_360_DAYS
360 day year with 30 day months.
Definition mtime_calendar.h:124
struct _datetime contains a struct _date and a struct _time element.
Definition mtime_datetime.h:36
Struct _julianday containing julian day parameters.
Definition mtime_julianDay.h:32