1 /* 2 +----------------------------------------------------------------------+ 3 | PHP Version 5 | 4 +----------------------------------------------------------------------+ 5 | Copyright (c) 1997-2009 The PHP Group | 6 +----------------------------------------------------------------------+ 7 | This source file is subject to version 3.01 of the PHP license, | 8 | that is bundled with this package in the file LICENSE, and is | 9 | available through the world-wide-web at the following url: | 10 | http://www.php.net/license/3_01.txt | 11 | If you did not receive a copy of the PHP license and are unable to | 12 | obtain it through the world-wide-web, please send a note to | 13 | license@php.net so we can mail you a copy immediately. | 14 +----------------------------------------------------------------------+ 15 | Authors: Derick Rethans <derick@derickrethans.nl> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 /* $Id: timelib.h,v 1.10.2.11.2.7 2008/12/31 11:17:36 sebastian Exp $ */ 20 21 #ifndef __TIMELIB_H__ 22 #define __TIMELIB_H__ 23 24 #include "timelib_structs.h" 25 #if HAVE_LIMITS_H 26 #include <limits.h> 27 #endif 28 29 #define TIMELIB_NONE 0x00 30 #define TIMELIB_OVERRIDE_TIME 0x01 31 #define TIMELIB_NO_CLONE 0x02 32 33 #define TIMELIB_SPECIAL_WEEKDAY 0x01 34 35 #ifndef LONG_MAX 36 #define LONG_MAX 2147483647L 37 #endif 38 39 #ifndef LONG_MIN 40 #define LONG_MIN (- LONG_MAX - 1) 41 #endif 42 43 #if defined(_MSC_VER) && !defined(strcasecmp) 44 #define strcasecmp stricmp 45 #endif 46 47 #if defined(_MSC_VER) && !defined(strncasecmp) 48 #define strncasecmp strnicmp 49 #endif 50 51 /* From dow.c */ 52 timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d); 53 timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d); 54 timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d); 55 timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d); 56 timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m); 57 void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy); 58 59 /* From parse_date.re */ 60 timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb); 61 void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options); 62 char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst); 63 const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void); 64 65 /* From tm2unixtime.c */ 66 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi); 67 68 /* From unixtime2tm.c */ 69 int timelib_apply_localtime(timelib_time *t, unsigned int localtime); 70 void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts); 71 void timelib_unixtime2local(timelib_time *tm, timelib_sll ts); 72 void timelib_update_from_sse(timelib_time *tm); 73 void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz); 74 75 /* From parse_tz.c */ 76 int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb); 77 timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb); 78 int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz); 79 timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz); 80 timelib_sll timelib_get_current_offset(timelib_time *t); 81 void timelib_dump_tzinfo(timelib_tzinfo *tz); 82 const timelib_tzdb *timelib_builtin_db(void); 83 const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count); 84 85 /* From timelib.c */ 86 timelib_tzinfo* timelib_tzinfo_ctor(char *name); 87 void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr); 88 void timelib_time_tz_name_update(timelib_time* tm, char* tz_name); 89 void timelib_tzinfo_dtor(timelib_tzinfo *tz); 90 timelib_tzinfo* timelib_tzinfo_clone(timelib_tzinfo *tz); 91 92 timelib_time* timelib_time_ctor(void); 93 void timelib_time_set_option(timelib_time* tm, int option, void* option_value); 94 void timelib_time_dtor(timelib_time* t); 95 96 timelib_time_offset* timelib_time_offset_ctor(void); 97 void timelib_time_offset_dtor(timelib_time_offset* t); 98 99 void timelib_error_container_dtor(timelib_error_container *errors); 100 101 signed long timelib_date_to_int(timelib_time *d, int *error); 102 void timelib_dump_date(timelib_time *d, int options); 103 104 void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec); 105 106 /* from astro.c */ 107 double timelib_ts_to_juliandate(timelib_sll ts); 108 int timelib_astro_rise_set_altitude(timelib_time *time, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit); 109 110 #endif 111