mtime 1.2.2
Loading...
Searching...
No Matches
mtime_calendar.h File Reference

Singleton Calendar connecting all supported calendar types. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NO_OF_DAYS_IN_A_MONTH_FOR_CAL_TYPE360   30
 
#define NO_OF_MONTHS_IN_A_YEAR   12
 
#define NO_OF_HOURS_IN_A_DAY   24
 
#define NO_OF_DAYS_IN_A_YEAR_FOR_CAL_TYPE360   360
 
#define NO_OF_DAYS_IN_A_YEAR_FOR_CAL_TYPE365   365
 
#define NO_OF_DAYS_IN_A_LEAP_YEAR   366
 
#define NO_OF_DAYS_IN_400_YEARS   146097
 
#define YEAR_UPPER_BOUND   2147483647
 
#define YEAR_LOWER_BOUND   -2147483648
 
#define POSIXSTRING_DAY_LOWER_BOUND   15
 
#define POSIXSTRING_MONTH_LOWER_BOUND   10
 
#define POSIXSTRING_YEAR_LOWER_BOUND   1582
 
#define POSIXSTRING_YEAR_UPPER_BOUND   9999
 
#define MAX_CALENDAR_STR_LEN   32
 provides a string length for toString.
 
#define MAX_DATETIME_STR_LEN   32
 
#define MAX_DATE_STR_LEN   32
 
#define MAX_TIME_STR_LEN   32
 
#define MAX_TIMEDELTA_STR_LEN   32
 
#define MAX_JULIANDAY_STR_LEN   32
 

Enumerations

enum  compare_return_val { equal_to = 0 , greater_than = 1 , less_than = -1 , compare_error = -128 }
 
enum  calendarType { CALENDAR_NOT_SET = 0 , PROLEPTIC_GREGORIAN = 1 , YEAR_OF_365_DAYS = 2 , YEAR_OF_360_DAYS = 3 }
 enum calendarType lists the calendarTypes supported. The values are used for selecting calendars. More...
 

Functions

void initCalendar (calendarType ct)
 To initialize a new calendar.
 
void freeCalendar (void)
 called to discard the selected calendar type.
 
calendarType getCalendarType (void)
 To query the current calendar type.
 
char * calendarToString (char *calendar)
 convert the calendar identifier into a human readable string.
 

Variables

const int NO_OF_SEC_IN_A_DAY
 
const int NO_OF_SEC_IN_A_HOUR
 
const int NO_OF_SEC_IN_A_MINUTE
 
const int NO_OF_MS_IN_A_DAY
 
const int NO_OF_MS_IN_HALF_DAY
 
const int NO_OF_MS_IN_A_HOUR
 
const int NO_OF_MS_IN_A_MINUTE
 
const int NO_OF_MS_IN_A_SECOND
 
const char initDummyTDString []
 
const char initDummyDString []
 
const char initDummyDTString []
 
const int nofDaysAfterARGMonthsInLeapYear [13]
 
const int nofDaysAfterARGMonthsInNonLeapYear [13]
 
const int nofDaysInARGMonthInLeapYear []
 
const int nofDaysInARGMonthIn365DayYear []
 
const int nofDaysInARGMonthIn360DayYear []
 
const int monthSpecificDeltaInMonthsLeapyear [12][13]
 
const int monthSpecificDeltaInMonths365 [12][13]
 
const int monthSpecificDeltaInMonths360 [12][13]
 
struct _julianday *(* date2julian )(struct _datetime *date, struct _julianday *julian)
 Function pointer connecting the Calendar to Julian routine. The pointed-to Function depends on the selected Calendar type.
 
struct _datetime *(* julian2date )(struct _julianday *julian, struct _datetime *date)
 Function pointer connecting Julian to Calendar routine. The pointed to Function depends on the selected Calendar type.
 

Detailed Description

Singleton Calendar connecting all supported calendar types.

Three calendar types are provided:

  • a proleptic Gregorian calendar
  • a calendar with 365 days per year without leap years
  • a calendar with 360 days per year and each month having 30 days

To use this library, a call to initCalendar() with the respective selector (enum calendarType) must be done first. The implementation is based on a singleton concept meaning that only one calendar can be active at a time. To release a calendar a call to freeCalendar() has to be done.

Author
Luis Kornblueh, Max Planck Institute for Meteorology
Rahul Sinha, Max Planck Institute for Meteorology
Date
March 2013
Note
Calendar type, once initialized, should not be changed.