#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
+#ifndef LONG_MAX
+#define LONG_MAX 2147483647L
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN (- LONG_MAX - 1)
+#endif
+
+
/* From dow.c */
int timelib_day_of_week(int y, int m, int d);
int timelib_daynr_from_weeknr(int y, int w, int d);
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
/* From unixtime2tm.c */
-int timelib_apply_localtime(timelib_time *t, uint localtime);
+int timelib_apply_localtime(timelib_time *t, unsigned int localtime);
void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts);
void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo* tz);
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
#include <string.h>
#include "datetime.h"
+#ifdef PHP_WIN32
+#define strcasecmp stricmp
+#define strtoll(s, f, b) _atoi64(s)
+#endif
+
#define TIMELIB_SECOND 1
#define TIMELIB_MINUTE 2
#define TIMELIB_HOUR 3
#include "timelib_structs.h"
typedef struct timelib_elems {
- uint c; /* Number of elements */
+ unsigned int c; /* Number of elements */
char **v; /* Values */
} timelib_elems;
typedef struct Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
- uint line, len;
+ unsigned int line, len;
struct timelib_time *time;
} Scanner;
#if 0
uchar *fill(Scanner *s, uchar *cursor){
if(!s->eof){
- uint cnt = s->tok - s->bot;
+ unsigned int cnt = s->tok - s->bot;
if(cnt){
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
/* $Id$ */
#include <stdio.h>
+#ifdef PHP_WIN32
+#include <winsock2.h>
+#else
#include <netinet/in.h>
+#endif
#include <string.h>
#include "datetime.h"
#include <string.h>
#include "datetime.h"
+#ifdef PHP_WIN32
+#define strcasecmp stricmp
+#define strtoll(s, f, b) _atoi64(s)
+#endif
+
#define TIMELIB_SECOND 1
#define TIMELIB_MINUTE 2
#define TIMELIB_HOUR 3
#include "timelib_structs.h"
typedef struct timelib_elems {
- uint c; /* Number of elements */
+ unsigned int c; /* Number of elements */
char **v; /* Values */
} timelib_elems;
typedef struct Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
- uint line, len;
+ unsigned int line, len;
struct timelib_time *time;
} Scanner;
#if 0
uchar *fill(Scanner *s, uchar *cursor){
if(!s->eof){
- uint cnt = s->tok - s->bot;
+ unsigned int cnt = s->tok - s->bot;
if(cnt){
memcpy(s->bot, s->tok, s->lim - s->tok);
s->tok = s->bot;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#ifdef PHP_WIN32
+#include <winsock2.h>
+#else
#include <netinet/in.h>
+#endif
-#if defined(WIN32) && _MSC_VER < 1300
+#if defined(PHP_WIN32) && _MSC_VER < 1300
typedef unsigned __int64 timelib_ull;
typedef __int64 timelib_sll;
#else
typedef signed long long timelib_sll;
#endif
+#if defined(_MSC_VER)
+#define int32_t __int32
+#define uint32_t unsigned __int32
+#endif
+
typedef struct ttinfo
{
int32_t offset;
typedef struct timelib_time_offset {
int32_t offset;
- uint leap_secs;
- uint is_dst;
+ unsigned int leap_secs;
+ unsigned int is_dst;
char *abbr;
} timelib_time_offset;
int z; /* GMT offset in minutes */
char *tz_abbr; /* Timezone abbreviation (display only) */
timelib_tzinfo *tz_info; /* Timezone structure */
- uint dst; /* Flag if we were parsing a DST zone */
+ unsigned int dst; /* Flag if we were parsing a DST zone */
timelib_rel_time relative;
timelib_sll sse; /* Seconds since epoch */
- uint have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day;
+ unsigned int have_time, have_date, have_zone, have_relative, have_weekday_relative, have_weeknr_day;
- uint sse_uptodate; /* !0 if the sse member is up to date with the date/time members */
- uint tim_uptodate; /* !0 if the date/time members are up to date with the sse member */
- uint is_localtime; /* 1 if the current struct represents localtime, 0 if it is in GMT */
- uint zone_type; /* 1 time offset,
+ 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 */
} timelib_time;
static timelib_sll do_years(int year)
{
- uint i;
+ unsigned int i;
timelib_sll res = 0;
if (year >= 1970) {
return res;
}
-static timelib_sll do_months(uint month, uint year)
+static timelib_sll do_months(unsigned int month, unsigned int year)
{
if (is_leap(year)) {
return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
}
}
-static timelib_sll do_days(uint day)
+static timelib_sll do_days(unsigned int day)
{
return ((day - 1) * SECS_PER_DAY);
}
-static timelib_sll do_time(uint hour, uint minute, uint second)
+static timelib_sll do_time(unsigned int hour, unsigned int minute, unsigned int second)
{
timelib_sll res = 0;
#include <stdio.h>
#include <string.h>
+#if defined(_MSC_VER)
+#define PHP_LL_CONST(n) n ## i64
+#else
+#define PHP_LL_CONST(n) n ## ll
+#endif
+
#include "datetime.h"
static int month_tab_leap[12] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
/* Guess why this might be for, it has to do with a pope ;-). It's also
* only valid for Great Brittain and it's colonies. It needs fixing for
* other locales. *sigh*, why is this crap so complex! */
- if (ts <= -6857352000ll) {
+ if (ts <= PHP_LL_CONST(-6857352000)) {
tmp_days -= 11;
}
/* Converts the time stored in the struct to localtime if localtime = true,
* otherwise it converts it to gmttime. This is only done when necessary
* ofcourse. */
-int timelib_apply_localtime(timelib_time *t, uint localtime)
+int timelib_apply_localtime(timelib_time *t, unsigned int localtime)
{
if (localtime) {
/* Converting from GMT time to local time */
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s", ×, &time_len) != FAILURE) {
/* We have no initial timestamp */
now = timelib_time_ctor();
- timelib_unixtime2local(now, (signed long long) time(NULL), tzi);
+ timelib_unixtime2local(now, (timelib_sll) time(NULL), tzi);
} else {
timelib_tzinfo_ctor(tzi);
RETURN_FALSE;