Back to index

php5  5.3.10
timelib.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2010 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Derick Rethans <derick@derickrethans.nl>                    |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 /* $Id: timelib.h 320481 2011-12-06 06:21:08Z derick $ */
00020 
00021 #ifndef __TIMELIB_H__
00022 #define __TIMELIB_H__
00023 
00024 #include "timelib_structs.h"
00025 #if HAVE_LIMITS_H
00026 #include <limits.h>
00027 #endif
00028 
00029 #define TIMELIB_VERSION 201102
00030 
00031 #define TIMELIB_NONE             0x00
00032 #define TIMELIB_OVERRIDE_TIME    0x01
00033 #define TIMELIB_NO_CLONE         0x02
00034 
00035 #define TIMELIB_UNSET   -99999
00036 
00037 #define TIMELIB_SPECIAL_WEEKDAY                   0x01
00038 #define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH      0x02
00039 #define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
00040 
00041 #ifndef LONG_MAX
00042 #define LONG_MAX 2147483647L
00043 #endif
00044 
00045 #ifndef LONG_MIN
00046 #define LONG_MIN (- LONG_MAX - 1)
00047 #endif
00048 
00049 #if defined(_MSC_VER) && !defined(strcasecmp)
00050 #define strcasecmp stricmp
00051 #endif
00052 
00053 #if defined(_MSC_VER) && !defined(strncasecmp)
00054 #define strncasecmp strnicmp
00055 #endif
00056 
00057 /* Function pointers */
00058 typedef timelib_tzinfo* (*timelib_tz_get_wrapper)(char *tzname, const timelib_tzdb *tzdb);
00059 
00060 /* From dow.c */
00061 timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
00062 timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
00063 timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d);
00064 timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
00065 timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
00066 void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy);
00067 int timelib_valid_time(timelib_sll h, timelib_sll i, timelib_sll s);
00068 int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d);
00069 
00070 /* From parse_date.re */
00071 timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
00072 timelib_time *timelib_parse_from_format(char *format, char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
00073 void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
00074 char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst);
00075 const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void);
00076 
00077 /* From parse_iso_intervals.re */
00078 void timelib_strtointerval(char *s, int len, 
00079                            timelib_time **begin, timelib_time **end, 
00080                                              timelib_rel_time **period, int *recurrences, 
00081                                              struct timelib_error_container **errors);
00082 
00083 
00084 /* From tm2unixtime.c */
00085 void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
00086 void timelib_do_normalize(timelib_time *base);
00087 void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt);
00088 
00089 /* From unixtime2tm.c */
00090 int timelib_apply_localtime(timelib_time *t, unsigned int localtime);
00091 void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts);
00092 void timelib_unixtime2local(timelib_time *tm, timelib_sll ts);
00093 void timelib_update_from_sse(timelib_time *tm);
00094 void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
00095 
00096 /* From parse_tz.c */
00097 int timelib_timezone_id_is_valid(char *timezone, const timelib_tzdb *tzdb);
00098 timelib_tzinfo *timelib_parse_tzfile(char *timezone, const timelib_tzdb *tzdb);
00099 int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz);
00100 timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz);
00101 timelib_sll timelib_get_current_offset(timelib_time *t);
00102 void timelib_dump_tzinfo(timelib_tzinfo *tz);
00103 const timelib_tzdb *timelib_builtin_db(void);
00104 const timelib_tzdb_index_entry *timelib_timezone_builtin_identifiers_list(int *count);
00105 
00106 /* From timelib.c */
00107 timelib_tzinfo* timelib_tzinfo_ctor(char *name);
00108 void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr);
00109 void timelib_time_tz_name_update(timelib_time* tm, char* tz_name);
00110 void timelib_tzinfo_dtor(timelib_tzinfo *tz);
00111 timelib_tzinfo* timelib_tzinfo_clone(timelib_tzinfo *tz);
00112 
00113 timelib_rel_time* timelib_rel_time_ctor(void);
00114 void timelib_rel_time_dtor(timelib_rel_time* t);
00115 timelib_rel_time* timelib_rel_time_clone(timelib_rel_time *tz);
00116 
00117 timelib_time* timelib_time_ctor(void);
00118 void timelib_time_set_option(timelib_time* tm, int option, void* option_value);
00119 void timelib_time_dtor(timelib_time* t);
00120 timelib_time* timelib_time_clone(timelib_time* orig);
00121 
00122 timelib_time_offset* timelib_time_offset_ctor(void);
00123 void timelib_time_offset_dtor(timelib_time_offset* t);
00124 
00125 void timelib_error_container_dtor(timelib_error_container *errors);
00126 
00127 signed long timelib_date_to_int(timelib_time *d, int *error);
00128 void timelib_dump_date(timelib_time *d, int options);
00129 void timelib_dump_rel_time(timelib_rel_time *d);
00130 
00131 void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec);
00132 
00133 /* from astro.c */
00134 double timelib_ts_to_juliandate(timelib_sll ts);
00135 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);
00136 
00137 /* from interval.c */
00138 timelib_rel_time *timelib_diff(timelib_time *one, timelib_time *two);
00139 
00140 #endif