2005-06-14 21:32:29 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| PHP Version 5 |
|
|
|
|
+----------------------------------------------------------------------+
|
2005-08-03 14:08:58 +00:00
|
|
|
| Copyright (c) 1997-2005 The PHP Group |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 3.0 of the PHP license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.php.net/license/3_0.txt. |
|
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2005-06-17 14:54:00 +00:00
|
|
|
| Authors: Derick Rethans <derick@derickrethans.nl> |
|
2005-06-14 21:32:29 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef __TIMELIB_STRUCTS_H__
|
|
|
|
#define __TIMELIB_STRUCTS_H__
|
|
|
|
|
2005-06-29 19:08:26 +00:00
|
|
|
#include <timelib_config.h>
|
|
|
|
|
2005-06-16 23:12:10 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INTTYPES_H)
|
|
|
|
#include <inttypes.h>
|
|
|
|
#elif defined(HAVE_STDINT_H)
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_INT32_T
|
|
|
|
# if SIZEOF_INT == 4
|
|
|
|
typedef int int32_t;
|
|
|
|
# elif SIZEOF_LONG == 4
|
|
|
|
typedef long int int32_t;
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_UINT32_T
|
|
|
|
# if SIZEOF_INT == 4
|
|
|
|
typedef unsigned int uint32_t;
|
|
|
|
# elif SIZEOF_LONG == 4
|
|
|
|
typedef unsigned long int uint32_t;
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
#include <stdio.h>
|
2005-06-16 23:12:10 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
2005-06-14 21:32:29 +00:00
|
|
|
#include <string.h>
|
2005-06-15 00:11:29 +00:00
|
|
|
#else
|
2005-06-16 23:12:10 +00:00
|
|
|
#include <strings.h>
|
2005-06-15 00:11:29 +00:00
|
|
|
#endif
|
2005-06-14 21:32:29 +00:00
|
|
|
|
2005-07-20 08:31:02 +00:00
|
|
|
#if defined(_MSC_VER)
|
2005-06-14 21:32:29 +00:00
|
|
|
typedef unsigned __int64 timelib_ull;
|
|
|
|
typedef __int64 timelib_sll;
|
|
|
|
#else
|
|
|
|
typedef unsigned long long timelib_ull;
|
|
|
|
typedef signed long long timelib_sll;
|
|
|
|
#endif
|
|
|
|
|
2005-06-15 00:11:29 +00:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#define int32_t __int32
|
|
|
|
#define uint32_t unsigned __int32
|
|
|
|
#endif
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
typedef struct ttinfo
|
|
|
|
{
|
|
|
|
int32_t offset;
|
|
|
|
int isdst;
|
|
|
|
unsigned int abbr_idx;
|
|
|
|
|
|
|
|
unsigned int isstdcnt;
|
|
|
|
unsigned int isgmtcnt;
|
|
|
|
} ttinfo;
|
|
|
|
|
|
|
|
typedef struct tlinfo
|
|
|
|
{
|
|
|
|
int32_t trans;
|
|
|
|
int32_t offset;
|
|
|
|
} tlinfo;
|
|
|
|
|
|
|
|
typedef struct timelib_tzinfo
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
uint32_t ttisgmtcnt;
|
|
|
|
uint32_t ttisstdcnt;
|
|
|
|
uint32_t leapcnt;
|
|
|
|
uint32_t timecnt;
|
|
|
|
uint32_t typecnt;
|
|
|
|
uint32_t charcnt;
|
|
|
|
|
|
|
|
int32_t *trans;
|
|
|
|
unsigned char *trans_idx;
|
|
|
|
|
|
|
|
ttinfo *type;
|
|
|
|
char *timezone_abbr;
|
|
|
|
|
|
|
|
tlinfo *leap_times;
|
|
|
|
} timelib_tzinfo;
|
|
|
|
|
|
|
|
typedef struct timelib_rel_time {
|
|
|
|
timelib_sll y, m, d; /* Years, Months and Days */
|
|
|
|
timelib_sll h, i, s; /* Hours, mInutes and Seconds */
|
|
|
|
|
|
|
|
int weekday; /* Stores the day in 'next monday' */
|
|
|
|
} timelib_rel_time;
|
|
|
|
|
|
|
|
typedef struct timelib_time_offset {
|
2005-06-15 07:23:27 +00:00
|
|
|
int32_t offset;
|
2005-06-15 00:11:29 +00:00
|
|
|
unsigned int leap_secs;
|
|
|
|
unsigned int is_dst;
|
2005-06-15 07:23:27 +00:00
|
|
|
char *abbr;
|
2005-06-18 19:23:58 +00:00
|
|
|
timelib_sll transistion_time;
|
2005-06-14 21:32:29 +00:00
|
|
|
} timelib_time_offset;
|
|
|
|
|
|
|
|
typedef struct timelib_time {
|
2005-06-15 07:23:27 +00:00
|
|
|
timelib_sll y, m, d; /* Year, Month, Day */
|
|
|
|
timelib_sll h, i, s; /* Hour, mInute, Second */
|
2005-06-15 11:01:07 +00:00
|
|
|
double f; /* Fraction */
|
2005-06-15 07:23:27 +00:00
|
|
|
int z; /* GMT offset in minutes */
|
|
|
|
char *tz_abbr; /* Timezone abbreviation (display only) */
|
|
|
|
timelib_tzinfo *tz_info; /* Timezone structure */
|
2005-06-17 14:54:00 +00:00
|
|
|
signed int dst; /* Flag if we were parsing a DST zone */
|
2005-06-14 21:32:29 +00:00
|
|
|
timelib_rel_time relative;
|
|
|
|
|
2005-06-15 07:23:27 +00:00
|
|
|
timelib_sll sse; /* Seconds since epoch */
|
2005-06-14 21:32:29 +00:00
|
|
|
|
2005-06-15 00:11:29 +00:00
|
|
|
unsigned int have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day;
|
2005-06-14 21:32:29 +00:00
|
|
|
|
2005-06-15 07:23:27 +00:00
|
|
|
unsigned int sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
|
|
|
|
unsigned int tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
|
|
|
|
unsigned int is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */
|
|
|
|
unsigned int zone_type; /* 1 time offset,
|
|
|
|
* 3 TimeZone identifier,
|
|
|
|
* 2 TimeZone abbreviation */
|
2005-06-14 21:32:29 +00:00
|
|
|
} timelib_time;
|
|
|
|
|
2005-07-20 08:31:02 +00:00
|
|
|
typedef struct _timelib_tz_lookup_table {
|
|
|
|
char *name;
|
|
|
|
int type;
|
|
|
|
int value;
|
|
|
|
char *full_tz_name;
|
|
|
|
} timelib_tz_lookup_table;
|
|
|
|
|
|
|
|
typedef struct _timelib_tzdb_index_entry {
|
|
|
|
char *id;
|
|
|
|
unsigned int pos;
|
|
|
|
} timelib_tzdb_index_entry;
|
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
#define TIMELIB_ZONETYPE_OFFSET 1
|
|
|
|
#define TIMELIB_ZONETYPE_ABBR 2
|
|
|
|
#define TIMELIB_ZONETYPE_ID 3
|
|
|
|
|
|
|
|
#define SECS_PER_DAY 86400
|
|
|
|
#define DAYS_PER_YEAR 365
|
|
|
|
#define DAYS_PER_LYEAR 366
|
|
|
|
|
2005-06-30 21:38:06 +00:00
|
|
|
#define timelib_is_leap(y) ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
|
2005-06-14 21:32:29 +00:00
|
|
|
|
|
|
|
#define DEBUG(s) if (0) { s }
|
2005-06-16 23:12:10 +00:00
|
|
|
|
2005-06-14 21:32:29 +00:00
|
|
|
#endif
|