/* -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 */ /******************************************************************************* * c0xcalendar.h * Proposed ISO/IEC C (C0X) calendar types and functions. * * Notes * The following preprocessor macro definition must be modified to suit * your runtime environment: * * _TIME_ERROR * * Unmodified, this header file assumes by default that the 'time_t' is * type 'int' and that only positive time values are valid, and defines the * macro above accordingly. * * References * See . * * See also * c0xcalendar.c * c0xtimezone.c * *------------------------------------------------------------------------------- * History * 1.0, 2001-12-27, David R Tribble. * First attempt. * * 1.1, 2001-12-30, David R Tribble. * Added the '_TIME_MIN' and '_TIME_MAX' macros. * * 1.2, 2002-01-05, David R Tribble. * Added 'ci_xxx_min' members to struct '_calendarinfo'. * * 1.3, 2002-01-13, David R Tribble. * Removed '_XXX_UNKNOWN' and '_XXX_NEVER' constants. * Removed '_CAL_OKAY' and '_CAL_ERROR' constants. * Default assumption is that 'time_t' is positive-only 'int'. * * 1.4, 2002-01-17, David R Tribble. * Added the 'ci_wday_1st' member. * * 1.5, 2002-01-28, David R Tribble. * Minor corrections. * * 1.6, 2002-01-31, David R Tribble. * Changed member '_timezone.tz_sec_west' to '.tz_min_west'. * * 1.7, 2002-02-12, David R Tribble. * Renamed constant '_TZ_GMT' to '_TZ_UTC'. * Changed the function signature of '_setcalendarzone()'. * * 1.8, 2002-02-13, David R Tribble. * Removed the '_gettimezonelist()' function. * * 1.9, 2002-02-17, David R Tribble. * Minor fixes applied. * * 1.9, 2002-02-17, David R Tribble. * Minor fixes applied. * * 1.10, 2002-02-17, David R Tribble. * Added an improved '_gettimezonelist()' function. * Defined some constants as non-macros. * Removed the 'xxx_vers' struct members and 'XXX_VERS' constants. * * 1.11, 2002-03-05, David R Tribble. * Added the '_XXX_VS' version macros. * Added 'ci_time_min' and 'ci_time_max' members to struct '_calendarinfo'. * Added the '_mktimezonename()' function. * Added 'restrict' qualifiers to the function prototypes. * Added the '_CAL_ERA_COMMON' constant. * * 1.12, 2002-03-13, David R Tribble. * Removed the '__STDC_CALENDAR_VERSION__' macro. * Removed the '_TIME_MIN' and '_TIME_MAX' constants. * Removed the '_gettimezonelist()' function. * Added the '_CAL_NAME_LOCAL' constant. * Added the '_convertcalendar()' function. * Added the 'ci_era_min' member of struct '_calendarinfo'. *******************************************************************************/ #ifndef _x_c0xcalendar_h #define _x_c0xcalendar_h 112 /* Identification */ #ifndef NO_H_IDENT static const char _x_c0xcalendar_h_rev[] = "@(#)$Header: c0xcalendar.h 1.12 2002-03-13 $"; #endif /* Standard includes */ #ifndef _stdc_stddef_h #include #endif #ifndef _stdc_limits_h #include #endif #ifndef _stdc_time_h #include #endif /* Local keywords */ /* Note: This does not seem to work for Microsoft C/C++ Compiler (v11) */ #if __STDC_VERSION__ < 199901 #define restrict #endif /******************************************************************************* * Public constants *******************************************************************************/ #define _CAL_YR_ERROR INT_MIN /* cal_year: Erroneous date */ #define _CAL_ERA_COMMON 0 /* cal_era: AD/CE */ #define _CAL_TYPE_GREGORIAN 0 /* Gregorian calendar type */ #define _CAL_NAME_GREGORIAN _cal_name_gregorian /* Gregorian calendar name */ #define _CAL_NAME_LOCAL _cal_name_gregorian /* Default local calendar name */ #ifndef _TIME_ERROR #define _TIME_ERROR ((time_t) -1) /* Erroneous time_t value */ #endif #define _TZ_UTC _tz_utc /* Timezone: UTC */ #define _TZ_LOCAL _tz_local /* Timezone: Local */ extern const char _cal_name_gregorian[]; extern const char _tz_local[]; extern const char _tz_utc[]; /******************************************************************************* * Public types *******************************************************************************/ /*------------------------------------------------------------------------------ * struct _timezone * Contains information about a supported timezone. */ #define _TIMEZONE_VS 20020223 struct _timezone { const char * tz_name; /* Full name */ const char * tz_abbr; /* Abbreviated name */ int tz_min_west; /* Minutes west of UTC */ int tz_dst; /* Daylight Savings Time effect */ int tz__r[2]; /* (Reserved for future use) */ }; /*------------------------------------------------------------------------------ * struct _calendarinfo * Contains information about a supported calendric system. */ #define _CALENDARINFO_VS 20020223 struct _calendarinfo { int ci_type; /* Calendar type */ const char * ci_name; /* Calendar name */ time_t ci_time_min; /* Minimum time_t value */ time_t ci_time_max; /* Maximum time_t value */ int ci_era_min; /* Minimum era number */ int ci_era_max; /* Maximum era number */ int ci_year_min; /* Minimum year number (1900) */ int ci_year_max; /* Maximum year number (2099) */ int ci_mon_min; /* Minimum month (12) */ int ci_mon_max; /* Maximum month (12) */ int ci_week_min; /* Minimum week of year (0) */ int ci_week_max; /* Maximum week of year (53) */ int ci_mday_min; /* Minimum day of month (1) */ int ci_mday_max; /* Maximum day of month (31) */ int ci_yday_min; /* Minimum day of year (1) */ int ci_yday_max; /* Maximum day of year (366) */ int ci_wday_min; /* Minimum day of week (1) */ int ci_wday_max; /* Maximum day of week (7) */ int ci_wday_1st; /* Weekday in the 1st week (4) */ int ci_hour_min; /* Minimum hour of day (0) */ int ci_hour_max; /* Maximum hour of day (23) */ int ci_min_max; /* Maximum minute (59) */ int ci_sec_max; /* Maximum second (59) */ int ci_leap_sec; /* Leap seconds in effect (0) */ int ci__r[4]; /* (Reserved for future use) */ }; /*------------------------------------------------------------------------------ * struct _calendar * Contains a broken-down date and time for a specific calendar type and * timezone. * * See also * struct tm */ #define _CALENDAR_VS 20020223 struct _calendar { int cal_type; /* Calendar type (_CAL_TYPE_XXX) */ const struct _timezone * cal_zone[2]; /* Timezones in effect */ int cal_era; /* Era [0] */ int cal_year; /* Year [1900,2099] */ int cal_mon; /* Month [1,12] */ int cal_mday; /* Day of month [1,31] */ int cal_yday; /* Day of year [1,366] */ int cal_wday; /* Day of week [1,7] */ int cal_week; /* Week of year [1,53] */ int cal_hour; /* Hour past midnight [0,23] */ int cal_min; /* Minute [0,59] */ int cal_sec; /* Second [0,59] */ long cal_nsec; /* Nanosecond [0,999999999] */ int cal_isdst; /* Daylight Savings Time [-1,1] */ int cal_leap_yr; /* Leap year in effect [0,1] */ short cal__nzones; /* (Max timezones in effect) */ short cal__r[13]; /* (Reserved for future use) */ }; /******************************************************************************* * Public functions *******************************************************************************/ extern int _calendardiff(struct _calendar */*restrict*/ __dif, const struct _calendar *__a, const struct _calendar *__b); extern int _calendarformat(char */*restrict*/ __buf, size_t __max, const char *__fmt, const struct _calendar *__cal); extern int _calendarscanf(const char *__buf, const char *__fmt, struct _calendar *__cal); extern int _checkcalendar(const struct _calendar *__cal); extern int _convertcalendar(struct _calendar *__dst, const struct _calendar *__src); extern int _getcalendar(struct _calendar *__cal, const char *__name, const char *__tzname); extern const struct _calendarinfo * _getcalendarinfo(const char *__name); extern int _getcalendartime(struct _calendar *__cal, time_t *__t); extern const struct _calendarinfo * _getcalendartype(int __type); extern int _gettimezone(const struct _timezone *__tz[2], const char *__tzname); extern int _mktimezonename(char *__buf, size_t __max, const struct _timezone *__tz[2]); extern int _setcalendartime(struct _calendar *__cal, time_t __t); extern int _setcalendarzone(struct _calendar *__cal, const struct _timezone *__tz[2]); /* Undo local keywords */ #if __STDC_VERSION__ < 199901 #undef restrict #endif #endif /* _x_c0xcalendar_h */ /* End c0xcalendar.h */ /* -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 7.0.3 for non-commercial use iQA/AwUBPJBCv3S9RCOKzj55EQKHIACg94NZ5H7m7nyTxR3Q92BjpWHYMx0An00Z L7gYO4SwBo7iCRGJQUpRsPpL =EiNH -----END PGP SIGNATURE----- */