123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef TIMEZONE_H
- #define TIMEZONE_H
- struct timezone;
- struct timezone_trans;
- typedef struct ttinfo
- {
- int offset;
- int isdst;
- unsigned int abbr_idx;
- unsigned int isstdcnt;
- unsigned int isgmtcnt;
- } ttinfo;
- struct timezone_transition
- {
- int start;
- int end;
- ttinfo info;
- };
- //C语言默认参数的方式
- #define TIMEZONE_NOFIXED INT_MIN
- struct timezone *timezone_open(char *name);
- const char * timezone_version_get();
- const char * timezone_name_get(struct timezone *tz);
- int timezone_offset_get(struct timezone *tz, int time); //time is gmt time
- int timezone_offset_get_local(struct timezone *tz, int time); //time is local time
- int timezone_transition_get(struct timezone *tz, int time, struct timezone_transition **trans);
- int timezone_fixed_offset(struct timezone *tz);
- int timezone_get_timestamp(struct timezone *tz, int time, int offset);
- int timezone_get_localtime(struct timezone *tz, int time, int offset);
- //return count, and first point.
- int timezone_transitions(struct timezone *tz, struct timezone_transition **trans);
- void timezone_dump_tzinfo(struct timezone *tz);
- void timezone_close(struct timezone *tz);
- //timezone trans的一个接口,用户两个时区进行转换的情况
- //这个时间的转换是非线程安全的
- //如果是在多线程下面运行,一定要保证每个线程运行一个转换实例
- //转换添加了cache,这样就算转多个货币对的情况,而且在tick更新,更新所有的货币对的情况。
- //可以进一步的提高性能。
- struct timezone_trans* timezone_trans_new(char *in , int inoffset, char *out, int outoffset, int cache_second);
- int timezone_trans_offset(struct timezone_trans *tz_trans, int time);
- int timezone_trans_in2gmt(struct timezone_trans *tz_trans, int time);
- int timezone_trans_gmt2out(struct timezone_trans *tz_trans, int newtime);
- void timezone_trans_free(struct timezone_trans *tz_trans);
- #ifdef _DEBUG
- #define TRACE0(sz) fprintf(stderr, "%s", sz)
- #define TRACE1(sz, p1) fprintf(stderr, sz, p1)
- #define TRACE2(sz, p1, p2) fprintf(stderr, sz, p1, p2)
- #define TRACE3(sz, p1, p2, p3) fprintf(stderr, sz, p1, p2, p3)
- #else
- #define TRACE0(sz)
- #define TRACE1(sz, p1)
- #define TRACE2(sz, p1, p2)
- #define TRACE3(sz, p1, p2, p3)
- #endif
- #endif
|