derick Mon Dec 19 13:00:40 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/date/lib astro.c astro.h
Modified files:
/php-src/ext/date config.m4 php_date.c
/php-src/ext/date/lib parse_date.c parse_date.re timelib.c
timelib.h timezonemap.h unixtime2tm.c
/php-src/ext/date/tests date_default_timezone_get-1.phpt
date_default_timezone_set-1.phpt
mktime-2.phpt
Log:
- MFH: Merged new timelib, which is a bit more cleverer
- MFH: Support "UTC" in strtotime() properly.
- MFH: Added astro code, which is going to form the base for the new sunfuncs.
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/config.m4?r1=1.10.2.1&r2=1.10.2.2&diff_format=u
Index: php-src/ext/date/config.m4
diff -u php-src/ext/date/config.m4:1.10.2.1 php-src/ext/date/config.m4:1.10.2.2
--- php-src/ext/date/config.m4:1.10.2.1 Mon Oct 3 20:21:01 2005
+++ php-src/ext/date/config.m4 Mon Dec 19 13:00:32 2005
@@ -1,11 +1,11 @@
-dnl $Id: config.m4,v 1.10.2.1 2005/10/03 20:21:01 sniper Exp $
+dnl $Id: config.m4,v 1.10.2.2 2005/12/19 13:00:32 derick Exp $
dnl config.m4 for date extension
sinclude(ext/date/lib/timelib.m4)
sinclude(lib/timelib.m4)
PHP_DATE_CFLAGS="[EMAIL PROTECTED]@/lib"
-timelib_sources="lib/dow.c lib/parse_date.c lib/parse_tz.c
+timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c"
PHP_NEW_EXTENSION(date, php_date.c $timelib_sources, no,, $PHP_DATE_CFLAGS)
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/php_date.c?r1=1.43.2.31&r2=1.43.2.32&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.31
php-src/ext/date/php_date.c:1.43.2.32
--- php-src/ext/date/php_date.c:1.43.2.31 Tue Dec 6 01:40:06 2005
+++ php-src/ext/date/php_date.c Mon Dec 19 13:00:32 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.31 2005/12/06 01:40:06 sniper Exp $ */
+/* $Id: php_date.c,v 1.43.2.32 2005/12/19 13:00:32 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -590,7 +590,9 @@
if (localtime) {
tzi = get_timezone_info(TSRMLS_C);
- timelib_unixtime2local(t, ts, tzi);
+ t->tz_info = tzi;
+ t->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(t, ts);
} else {
tzi = NULL;
timelib_unixtime2gmt(t, ts);
@@ -618,7 +620,9 @@
if (!localtime) {
TSRMLS_FETCH();
tzi = get_timezone_info(TSRMLS_C);
- timelib_unixtime2local(t, ts, tzi);
+ t->tz_info = tzi;
+ t->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(t, ts);
} else {
tzi = NULL;
timelib_unixtime2gmt(t, ts);
@@ -797,13 +801,17 @@
snprintf(initial_ts, 24, "@%lu", preset_ts);
t = timelib_strtotime(initial_ts, strlen(initial_ts), &error1,
DATE_TIMEZONEDB); /* we ignore the error here, as this should never fail */
timelib_update_ts(t, tzi);
- timelib_unixtime2local(now, t->sse, tzi);
+ now->tz_info = tzi;
+ now->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(now, t->sse);
timelib_time_dtor(t);
efree(initial_ts);
} 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, (timelib_sll) time(NULL), tzi);
+ now->tz_info = tzi;
+ now->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(now, (timelib_sll) time(NULL));
} else {
RETURN_FALSE;
}
@@ -814,7 +822,7 @@
ts = timelib_date_to_int(t, &error2);
/* if tz_info is not a copy, avoid double free */
- if (now->tz_info != tzi) {
+ if (now->tz_info != tzi && now->tz_info) {
timelib_tzinfo_dtor(now->tz_info);
}
if (t->tz_info != tzi) {
@@ -851,7 +859,9 @@
timelib_unixtime2gmt(now, (timelib_sll) time(NULL));
} else {
tzi = get_timezone_info(TSRMLS_C);
- timelib_unixtime2local(now, (timelib_sll) time(NULL), tzi);
+ now->tz_info = tzi;
+ now->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(now, (timelib_sll) time(NULL));
}
/* Fill in the new data */
switch (ZEND_NUM_ARGS()) {
@@ -987,7 +997,9 @@
timelib_unixtime2gmt(ts, (timelib_sll) timestamp);
} else {
tzi = get_timezone_info(TSRMLS_C);
- timelib_unixtime2local(ts, (timelib_sll) timestamp, tzi);
+ ts->tz_info = tzi;
+ ts->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(ts, (timelib_sll) timestamp);
}
ta.tm_sec = ts->s;
ta.tm_min = ts->i;
@@ -1080,7 +1092,9 @@
tzi = get_timezone_info(TSRMLS_C);
ts = timelib_time_ctor();
- timelib_unixtime2local(ts, (timelib_sll) timestamp, tzi);
+ ts->tz_info = tzi;
+ ts->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(ts, (timelib_sll) timestamp);
array_init(return_value);
@@ -1124,7 +1138,9 @@
tzi = get_timezone_info(TSRMLS_C);
ts = timelib_time_ctor();
- timelib_unixtime2local(ts, (timelib_sll) timestamp, tzi);
+ ts->tz_info = tzi;
+ ts->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(ts, (timelib_sll) timestamp);
array_init(return_value);
@@ -1239,14 +1255,14 @@
static void date_object_free_storage_timezone(void *object TSRMLS_DC)
{
- php_date_obj *intern = (php_date_obj *)object;
-
+ php_timezone_obj *intern = (php_timezone_obj *)object;
+
if (intern->std.properties) {
zend_hash_destroy(intern->std.properties);
efree(intern->std.properties);
intern->std.properties = NULL;
}
-
+
efree(object);
}
@@ -1296,7 +1312,9 @@
}
now = timelib_time_ctor();
- timelib_unixtime2local(now, (timelib_sll) time(NULL), tzi);
+ now->tz_info = tzi;
+ now->zone_type = TIMELIB_ZONETYPE_ID;
+ timelib_unixtime2local(now, (timelib_sll) time(NULL));
timelib_fill_holes(dateobj->time, now, 0);
timelib_update_ts(dateobj->time, tzi);
@@ -1390,7 +1408,7 @@
timelib_tzinfo_dtor(dateobj->time->tz_info);
}
timelib_set_timezone(dateobj->time, timelib_tzinfo_clone(tzobj->tz));
- timelib_unixtime2local(dateobj->time, dateobj->time->sse,
dateobj->time->tz_info);
+ timelib_unixtime2local(dateobj->time, dateobj->time->sse);
}
PHP_FUNCTION(date_offset_get)
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/parse_date.c?r1=1.29.2.21&r2=1.29.2.22&diff_format=u
Index: php-src/ext/date/lib/parse_date.c
diff -u php-src/ext/date/lib/parse_date.c:1.29.2.21
php-src/ext/date/lib/parse_date.c:1.29.2.22
--- php-src/ext/date/lib/parse_date.c:1.29.2.21 Sun Dec 18 20:01:22 2005
+++ php-src/ext/date/lib/parse_date.c Mon Dec 19 13:00:32 2005
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.11 on Sun Dec 18 21:58:22 2005 */
+/* Generated by re2c 0.9.12.dev on Mon Dec 19 11:52:26 2005 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.c,v 1.29.2.21 2005/12/18 20:01:22 sniper Exp $ */
+/* $Id: parse_date.c,v 1.29.2.22 2005/12/19 13:00:32 derick Exp $ */
#include "timelib.h"
@@ -173,6 +173,10 @@
{ NULL, 0, 0, NULL },
};
+static timelib_tz_lookup_table timelib_timezone_utc[] = {
+ { "utc", 0, 0, "UTC" },
+};
+
static timelib_relunit const timelib_relunit_lookup[] = {
{ "sec", TIMELIB_SECOND, 1 },
{ "secs", TIMELIB_SECOND, 1 },
@@ -583,10 +587,12 @@
int first_found = 0;
timelib_tz_lookup_table *tp, *first_found_elem;
timelib_tz_lookup_table *fmp;
-
- if (gmtoffset == -1 && !strcmp(word, "UTC")) {
- goto skip_name_match;
+
+ if (strcasecmp("utc", word) == 0)
+ {
+ return timelib_timezone_utc;
}
+
for (tp = timelib_timezone_lookup; tp->name; tp++) {
if (strcasecmp(word, tp->name) == 0) {
if (!first_found) {
@@ -604,7 +610,7 @@
if (first_found) {
return first_found_elem;
}
-skip_name_match:
+
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
@@ -723,7 +729,7 @@
std:
s->tok = cursor;
s->len = 0;
-#line 832 "ext/date/lib/parse_date.re"
+#line 838 "ext/date/lib/parse_date.re"
{
@@ -762,7 +768,7 @@
0, 0, 0, 0, 0, 0, 0, 0,
};
-#line 766 "ext/date/lib/parse_date.c"
+#line 772 "ext/date/lib/parse_date.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -854,7 +860,7 @@
yy3:
YYDEBUG(3, *YYCURSOR);
-#line 1327 "ext/date/lib/parse_date.re"
+#line 1333 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
@@ -864,7 +870,7 @@
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
-#line 861 "ext/date/lib/parse_date.c"
+#line 867 "ext/date/lib/parse_date.c"
yy4:
YYDEBUG(4, *YYCURSOR);
yych = *++YYCURSOR;
@@ -982,13 +988,13 @@
yy8:
YYDEBUG(8, *YYCURSOR);
-#line 1393 "ext/date/lib/parse_date.re"
+#line 1399 "ext/date/lib/parse_date.re"
{
/* printf("unexpected character: #%d, %c ", *s->tok, *s->tok); */
s->errors++;
goto std;
}
-#line 975 "ext/date/lib/parse_date.c"
+#line 981 "ext/date/lib/parse_date.c"
yy9:
YYDEBUG(9, *YYCURSOR);
yyaccept = 0;
@@ -2042,11 +2048,11 @@
yy45:
YYDEBUG(45, *YYCURSOR);
-#line 1382 "ext/date/lib/parse_date.re"
+#line 1388 "ext/date/lib/parse_date.re"
{
goto std;
}
-#line 1954 "ext/date/lib/parse_date.c"
+#line 1960 "ext/date/lib/parse_date.c"
yy46:
YYDEBUG(46, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2058,12 +2064,12 @@
yy48:
YYDEBUG(48, *YYCURSOR);
-#line 1387 "ext/date/lib/parse_date.re"
+#line 1393 "ext/date/lib/parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
}
-#line 1965 "ext/date/lib/parse_date.c"
+#line 1971 "ext/date/lib/parse_date.c"
yy49:
YYDEBUG(49, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2271,7 +2277,7 @@
yy68:
YYDEBUG(68, *YYCURSOR);
-#line 1366 "ext/date/lib/parse_date.re"
+#line 1372 "ext/date/lib/parse_date.re"
{
timelib_ull i;
DEBUG_OUTPUT("relative");
@@ -2286,7 +2292,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 2146 "ext/date/lib/parse_date.c"
+#line 2152 "ext/date/lib/parse_date.c"
yy69:
YYDEBUG(69, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3263,7 +3269,7 @@
yy173:
YYDEBUG(173, *YYCURSOR);
-#line 1310 "ext/date/lib/parse_date.re"
+#line 1316 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior;
@@ -3279,7 +3285,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 2923 "ext/date/lib/parse_date.c"
+#line 2929 "ext/date/lib/parse_date.c"
yy174:
YYDEBUG(174, *YYCURSOR);
yych = *++YYCURSOR;
@@ -5041,7 +5047,7 @@
yy342:
YYDEBUG(342, *YYCURSOR);
-#line 1294 "ext/date/lib/parse_date.re"
+#line 1300 "ext/date/lib/parse_date.re"
{
const timelib_relunit* relunit;
DEBUG_OUTPUT("daytext");
@@ -5056,7 +5062,7 @@
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
-#line 4360 "ext/date/lib/parse_date.c"
+#line 4366 "ext/date/lib/parse_date.c"
yy343:
YYDEBUG(343, *YYCURSOR);
yyaccept = 1;
@@ -6048,7 +6054,7 @@
yy406:
YYDEBUG(406, *YYCURSOR);
-#line 1113 "ext/date/lib/parse_date.re"
+#line 1119 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datetextual | datenoyear");
TIMELIB_INIT;
@@ -6060,7 +6066,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 5236 "ext/date/lib/parse_date.c"
+#line 5242 "ext/date/lib/parse_date.c"
yy407:
YYDEBUG(407, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6271,7 +6277,7 @@
yy428:
YYDEBUG(428, *YYCURSOR);
-#line 1338 "ext/date/lib/parse_date.re"
+#line 1344 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong |
dateshortwithtimelongtz");
@@ -6298,7 +6304,7 @@
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 5430 "ext/date/lib/parse_date.c"
+#line 5436 "ext/date/lib/parse_date.c"
yy429:
YYDEBUG(429, *YYCURSOR);
yyaccept = 7;
@@ -6657,7 +6663,7 @@
yy465:
YYDEBUG(465, *YYCURSOR);
-#line 1087 "ext/date/lib/parse_date.re"
+#line 1093 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoday");
TIMELIB_INIT;
@@ -6669,7 +6675,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 5727 "ext/date/lib/parse_date.c"
+#line 5733 "ext/date/lib/parse_date.c"
yy466:
YYDEBUG(466, *YYCURSOR);
yyaccept = 6;
@@ -7042,7 +7048,7 @@
yy491:
YYDEBUG(491, *YYCURSOR);
-#line 1225 "ext/date/lib/parse_date.re"
+#line 1231 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pgtextshort");
TIMELIB_INIT;
@@ -7054,7 +7060,7 @@
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 6060 "ext/date/lib/parse_date.c"
+#line 6066 "ext/date/lib/parse_date.c"
yy492:
YYDEBUG(492, *YYCURSOR);
yych = *++YYCURSOR;
@@ -8887,7 +8893,7 @@
yy593:
YYDEBUG(593, *YYCURSOR);
-#line 1279 "ext/date/lib/parse_date.re"
+#line 1285 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("ago");
TIMELIB_INIT;
@@ -8901,7 +8907,7 @@
TIMELIB_DEINIT;
return TIMELIB_AGO;
}
-#line 7703 "ext/date/lib/parse_date.c"
+#line 7709 "ext/date/lib/parse_date.c"
yy594:
YYDEBUG(594, *YYCURSOR);
yyaccept = 1;
@@ -11235,7 +11241,7 @@
yy703:
YYDEBUG(703, *YYCURSOR);
-#line 1126 "ext/date/lib/parse_date.re"
+#line 1132 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoyearrev");
TIMELIB_INIT;
@@ -11246,7 +11252,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 9824 "ext/date/lib/parse_date.c"
+#line 9830 "ext/date/lib/parse_date.c"
yy704:
YYDEBUG(704, *YYCURSOR);
yyaccept = 10;
@@ -11356,7 +11362,7 @@
yy714:
YYDEBUG(714, *YYCURSOR);
-#line 916 "ext/date/lib/parse_date.re"
+#line 922 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
@@ -11372,7 +11378,7 @@
TIMELIB_DEINIT;
return TIMELIB_TIME12;
}
-#line 9928 "ext/date/lib/parse_date.c"
+#line 9934 "ext/date/lib/parse_date.c"
yy715:
YYDEBUG(715, *YYCURSOR);
yych = *++YYCURSOR;
@@ -11392,7 +11398,7 @@
yy717:
YYDEBUG(717, *YYCURSOR);
-#line 933 "ext/date/lib/parse_date.re"
+#line 939 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -11415,7 +11421,7 @@
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 9965 "ext/date/lib/parse_date.c"
+#line 9971 "ext/date/lib/parse_date.c"
yy718:
YYDEBUG(718, *YYCURSOR);
yyaccept = 11;
@@ -11658,7 +11664,7 @@
yy743:
YYDEBUG(743, *YYCURSOR);
-#line 1060 "ext/date/lib/parse_date.re"
+#line 1066 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datefull");
TIMELIB_INIT;
@@ -11671,7 +11677,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL;
}
-#line 10169 "ext/date/lib/parse_date.c"
+#line 10175 "ext/date/lib/parse_date.c"
yy744:
YYDEBUG(744, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12306,7 +12312,7 @@
yy812:
YYDEBUG(812, *YYCURSOR);
-#line 1074 "ext/date/lib/parse_date.re"
+#line 1080 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pointed date");
TIMELIB_INIT;
@@ -12318,7 +12324,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 10678 "ext/date/lib/parse_date.c"
+#line 10684 "ext/date/lib/parse_date.c"
yy813:
YYDEBUG(813, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12899,7 +12905,7 @@
yy858:
YYDEBUG(858, *YYCURSOR);
-#line 1047 "ext/date/lib/parse_date.re"
+#line 1053 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnudateshort");
TIMELIB_INIT;
@@ -12911,7 +12917,7 @@
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 11179 "ext/date/lib/parse_date.c"
+#line 11185 "ext/date/lib/parse_date.c"
yy859:
YYDEBUG(859, *YYCURSOR);
yyaccept = 12;
@@ -12994,7 +13000,7 @@
yy867:
YYDEBUG(867, *YYCURSOR);
-#line 1020 "ext/date/lib/parse_date.re"
+#line 1026 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("americanshort | american");
TIMELIB_INIT;
@@ -13008,7 +13014,7 @@
TIMELIB_DEINIT;
return TIMELIB_AMERICAN;
}
-#line 11258 "ext/date/lib/parse_date.c"
+#line 11264 "ext/date/lib/parse_date.c"
yy868:
YYDEBUG(868, *YYCURSOR);
yyaccept = 13;
@@ -13257,7 +13263,7 @@
yy900:
YYDEBUG(900, *YYCURSOR);
-#line 1251 "ext/date/lib/parse_date.re"
+#line 1257 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("clf");
@@ -13275,7 +13281,7 @@
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 11459 "ext/date/lib/parse_date.c"
+#line 11465 "ext/date/lib/parse_date.c"
yy901:
YYDEBUG(901, *YYCURSOR);
yyaccept = 14;
@@ -13671,7 +13677,7 @@
yy953:
YYDEBUG(953, *YYCURSOR);
-#line 1238 "ext/date/lib/parse_date.re"
+#line 1244 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pgtextreverse");
TIMELIB_INIT;
@@ -13683,7 +13689,7 @@
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 11759 "ext/date/lib/parse_date.c"
+#line 11765 "ext/date/lib/parse_date.c"
yy954:
YYDEBUG(954, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13816,7 +13822,7 @@
yy965:
YYDEBUG(965, *YYCURSOR);
-#line 1270 "ext/date/lib/parse_date.re"
+#line 1276 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("year4");
TIMELIB_INIT;
@@ -13824,7 +13830,7 @@
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 11875 "ext/date/lib/parse_date.c"
+#line 11881 "ext/date/lib/parse_date.c"
yy966:
YYDEBUG(966, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13960,7 +13966,7 @@
yy974:
YYDEBUG(974, *YYCURSOR);
-#line 1100 "ext/date/lib/parse_date.re"
+#line 1106 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenodayrev");
TIMELIB_INIT;
@@ -13972,7 +13978,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 12002 "ext/date/lib/parse_date.c"
+#line 12008 "ext/date/lib/parse_date.c"
yy975:
YYDEBUG(975, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14181,7 +14187,7 @@
yy994:
YYDEBUG(994, *YYCURSOR);
-#line 1206 "ext/date/lib/parse_date.re"
+#line 1212 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweek");
@@ -14199,7 +14205,7 @@
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 12189 "ext/date/lib/parse_date.c"
+#line 12195 "ext/date/lib/parse_date.c"
yy995:
YYDEBUG(995, *YYCURSOR);
++YYCURSOR;
@@ -14207,7 +14213,7 @@
yy996:
YYDEBUG(996, *YYCURSOR);
-#line 1187 "ext/date/lib/parse_date.re"
+#line 1193 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweekday");
@@ -14225,7 +14231,7 @@
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 12211 "ext/date/lib/parse_date.c"
+#line 12217 "ext/date/lib/parse_date.c"
yy997:
YYDEBUG(997, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14294,7 +14300,7 @@
yy1000:
YYDEBUG(1000, *YYCURSOR);
-#line 1174 "ext/date/lib/parse_date.re"
+#line 1180 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pgydotd");
TIMELIB_INIT;
@@ -14306,7 +14312,7 @@
TIMELIB_DEINIT;
return TIMELIB_PG_YEARDAY;
}
-#line 12284 "ext/date/lib/parse_date.c"
+#line 12290 "ext/date/lib/parse_date.c"
yy1001:
YYDEBUG(1001, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14412,7 +14418,7 @@
yy1007:
YYDEBUG(1007, *YYCURSOR);
-#line 1138 "ext/date/lib/parse_date.re"
+#line 1144 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenocolon");
TIMELIB_INIT;
@@ -14423,7 +14429,7 @@
TIMELIB_DEINIT;
return TIMELIB_DATE_NOCOLON;
}
-#line 12383 "ext/date/lib/parse_date.c"
+#line 12389 "ext/date/lib/parse_date.c"
yy1008:
YYDEBUG(1008, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14521,7 +14527,7 @@
yy1018:
YYDEBUG(1018, *YYCURSOR);
-#line 1150 "ext/date/lib/parse_date.re"
+#line 1156 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx");
@@ -14544,7 +14550,7 @@
TIMELIB_DEINIT;
return TIMELIB_XMLRPC_SOAP;
}
-#line 12482 "ext/date/lib/parse_date.c"
+#line 12488 "ext/date/lib/parse_date.c"
yy1019:
YYDEBUG(1019, *YYCURSOR);
yych = *++YYCURSOR;
@@ -15160,7 +15166,7 @@
yy1109:
YYDEBUG(1109, *YYCURSOR);
-#line 1035 "ext/date/lib/parse_date.re"
+#line 1041 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601date | iso8601dateslash | dateslash");
TIMELIB_INIT;
@@ -15171,7 +15177,7 @@
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 12927 "ext/date/lib/parse_date.c"
+#line 12933 "ext/date/lib/parse_date.c"
yy1110:
YYDEBUG(1110, *YYCURSOR);
yyaccept = 19;
@@ -16124,7 +16130,7 @@
yy1201:
YYDEBUG(1201, *YYCURSOR);
-#line 957 "ext/date/lib/parse_date.re"
+#line 963 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
@@ -16145,7 +16151,7 @@
TIMELIB_DEINIT;
return TIMELIB_GNU_NOCOLON;
}
-#line 13715 "ext/date/lib/parse_date.c"
+#line 13721 "ext/date/lib/parse_date.c"
yy1202:
YYDEBUG(1202, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16242,7 +16248,7 @@
yy1209:
YYDEBUG(1209, *YYCURSOR);
-#line 1002 "ext/date/lib/parse_date.re"
+#line 1008 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("iso8601nocolon");
@@ -16259,7 +16265,7 @@
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
}
-#line 13813 "ext/date/lib/parse_date.c"
+#line 13819 "ext/date/lib/parse_date.c"
yy1210:
YYDEBUG(1210, *YYCURSOR);
yyaccept = 22;
@@ -16578,7 +16584,7 @@
yy1234:
YYDEBUG(1234, *YYCURSOR);
-#line 892 "ext/date/lib/parse_date.re"
+#line 898 "ext/date/lib/parse_date.re"
{
timelib_ull i;
@@ -16601,7 +16607,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14099 "ext/date/lib/parse_date.c"
+#line 14105 "ext/date/lib/parse_date.c"
yy1235:
YYDEBUG(1235, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16683,7 +16689,7 @@
yy1243:
YYDEBUG(1243, *YYCURSOR);
-#line 880 "ext/date/lib/parse_date.re"
+#line 886 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("tomorrow");
TIMELIB_INIT;
@@ -16694,7 +16700,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14174 "ext/date/lib/parse_date.c"
+#line 14180 "ext/date/lib/parse_date.c"
yy1244:
YYDEBUG(1244, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16708,7 +16714,7 @@
yy1246:
YYDEBUG(1246, *YYCURSOR);
-#line 870 "ext/date/lib/parse_date.re"
+#line 876 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("midnight | today");
TIMELIB_INIT;
@@ -16717,7 +16723,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14191 "ext/date/lib/parse_date.c"
+#line 14197 "ext/date/lib/parse_date.c"
yy1247:
YYDEBUG(1247, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16812,7 +16818,7 @@
yy1255:
YYDEBUG(1255, *YYCURSOR);
-#line 849 "ext/date/lib/parse_date.re"
+#line 855 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("now");
TIMELIB_INIT;
@@ -16820,7 +16826,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14276 "ext/date/lib/parse_date.c"
+#line 14282 "ext/date/lib/parse_date.c"
yy1256:
YYDEBUG(1256, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16846,7 +16852,7 @@
yy1258:
YYDEBUG(1258, *YYCURSOR);
-#line 858 "ext/date/lib/parse_date.re"
+#line 864 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("noon");
TIMELIB_INIT;
@@ -16857,7 +16863,7 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14307 "ext/date/lib/parse_date.c"
+#line 14313 "ext/date/lib/parse_date.c"
yy1259:
YYDEBUG(1259, *YYCURSOR);
yych = *++YYCURSOR;
@@ -16926,7 +16932,7 @@
yy1267:
YYDEBUG(1267, *YYCURSOR);
-#line 837 "ext/date/lib/parse_date.re"
+#line 843 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("yesterday");
TIMELIB_INIT;
@@ -16937,10 +16943,10 @@
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 14369 "ext/date/lib/parse_date.c"
+#line 14375 "ext/date/lib/parse_date.c"
}
}
-#line 1398 "ext/date/lib/parse_date.re"
+#line 1404 "ext/date/lib/parse_date.re"
}
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/parse_date.re?r1=1.26.2.18&r2=1.26.2.19&diff_format=u
Index: php-src/ext/date/lib/parse_date.re
diff -u php-src/ext/date/lib/parse_date.re:1.26.2.18
php-src/ext/date/lib/parse_date.re:1.26.2.19
--- php-src/ext/date/lib/parse_date.re:1.26.2.18 Sun Dec 18 16:15:44 2005
+++ php-src/ext/date/lib/parse_date.re Mon Dec 19 13:00:37 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.re,v 1.26.2.18 2005/12/18 16:15:44 iliaa Exp $ */
+/* $Id: parse_date.re,v 1.26.2.19 2005/12/19 13:00:37 derick Exp $ */
#include "timelib.h"
@@ -171,6 +171,10 @@
{ NULL, 0, 0, NULL },
};
+static timelib_tz_lookup_table timelib_timezone_utc[] = {
+ { "utc", 0, 0, "UTC" },
+};
+
static timelib_relunit const timelib_relunit_lookup[] = {
{ "sec", TIMELIB_SECOND, 1 },
{ "secs", TIMELIB_SECOND, 1 },
@@ -581,10 +585,11 @@
int first_found = 0;
timelib_tz_lookup_table *tp, *first_found_elem;
timelib_tz_lookup_table *fmp;
-
- if (gmtoffset == -1 && !strcmp(word, "UTC")) {
- goto skip_name_match;
+
+ if (strcasecmp("utc", word) == 0) {
+ return timelib_timezone_utc;
}
+
for (tp = timelib_timezone_lookup; tp->name; tp++) {
if (strcasecmp(word, tp->name) == 0) {
if (!first_found) {
@@ -602,7 +607,7 @@
if (first_found) {
return first_found_elem;
}
-skip_name_match:
+
/* Still didn't find anything, let's find the zone solely based on
* offset/isdst then */
for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) {
@@ -792,7 +797,7 @@
datefull = day ([ -.])* monthtext ([ -.])* year;
datenoday = monthtext ([ -.])* year4;
datenodayrev = year4 ([ -.])* monthtext;
-datetextual = monthtext ([ -.])* day [,.stndrh ]* year;
+datetextual = monthtext ([ -.])* day [,.stndrh ]* year;
datenoyear = monthtext ([ -.])* day [,.stndrh ]*;
datenoyearrev = day ([ -.])* monthtext;
datenocolon = year4 monthlz daylz;
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/timelib.c?r1=1.7.2.1&r2=1.7.2.2&diff_format=u
Index: php-src/ext/date/lib/timelib.c
diff -u php-src/ext/date/lib/timelib.c:1.7.2.1
php-src/ext/date/lib/timelib.c:1.7.2.2
--- php-src/ext/date/lib/timelib.c:1.7.2.1 Wed Oct 19 21:08:32 2005
+++ php-src/ext/date/lib/timelib.c Mon Dec 19 13:00:37 2005
@@ -16,10 +16,11 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib.c,v 1.7.2.1 2005/10/19 21:08:32 derick Exp $ */
+/* $Id: timelib.c,v 1.7.2.2 2005/12/19 13:00:37 derick Exp $ */
#include "timelib.h"
#include <ctype.h>
+#include <math.h>
#define TIMELIB_TIME_FREE(m) \
if (m) { \
@@ -139,6 +140,13 @@
return (signed long) d->sse;
}
+void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec)
+{
+ *hour = floor(h);
+ *min = floor((h - *hour) * 60);
+ *sec = (h - *hour - ((float) *min / 60)) * 3600;
+}
+
void timelib_dump_date(timelib_time *d, int options)
{
if ((options & 2) == 2) {
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/timelib.h?r1=1.10.2.6&r2=1.10.2.7&diff_format=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.10.2.6
php-src/ext/date/lib/timelib.h:1.10.2.7
--- php-src/ext/date/lib/timelib.h:1.10.2.6 Mon Dec 12 19:45:01 2005
+++ php-src/ext/date/lib/timelib.h Mon Dec 19 13:00:37 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib.h,v 1.10.2.6 2005/12/12 19:45:01 sniper Exp $ */
+/* $Id: timelib.h,v 1.10.2.7 2005/12/19 13:00:37 derick Exp $ */
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
@@ -62,7 +62,7 @@
/* From unixtime2tm.c */
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_unixtime2local(timelib_time *tm, timelib_sll ts);
void timelib_update_from_sse(timelib_time *tm);
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz);
@@ -91,4 +91,10 @@
signed long timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
+void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec);
+
+/* from astro.c */
+double timelib_ts_to_juliandate(timelib_sll ts);
+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);
+
#endif
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/timezonemap.h?r1=1.1.2.4&r2=1.1.2.5&diff_format=u
Index: php-src/ext/date/lib/timezonemap.h
diff -u php-src/ext/date/lib/timezonemap.h:1.1.2.4
php-src/ext/date/lib/timezonemap.h:1.1.2.5
--- php-src/ext/date/lib/timezonemap.h:1.1.2.4 Mon Nov 28 23:49:25 2005
+++ php-src/ext/date/lib/timezonemap.h Mon Dec 19 13:00:37 2005
@@ -885,7 +885,6 @@
{ "gmt", 0, 0, "GB" },
{ "gmt", 0, 0, "GB-Eire" },
{ "gmt", 0, 0, "GMT" },
- { "utc", 0, 0, "UTC" },
{ "gmt", 0, 0, "Iceland" },
{ "gst", 0, 14400, "Asia/Dubai" },
{ "gst", 0, 14400, "Asia/Bahrain" },
@@ -1622,6 +1621,7 @@
{ "r", 0, -18000, NULL },
{ "s", 0, -21600, NULL },
{ "t", 0, -25200, NULL },
+ { "utc", 0, 0, "UTC" },
{ "u", 0, -28800, NULL },
{ "v", 0, -32400, NULL },
{ "w", 0, -36000, NULL },
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/unixtime2tm.c?r1=1.12&r2=1.12.2.1&diff_format=u
Index: php-src/ext/date/lib/unixtime2tm.c
diff -u php-src/ext/date/lib/unixtime2tm.c:1.12
php-src/ext/date/lib/unixtime2tm.c:1.12.2.1
--- php-src/ext/date/lib/unixtime2tm.c:1.12 Wed Aug 3 14:06:50 2005
+++ php-src/ext/date/lib/unixtime2tm.c Mon Dec 19 13:00:37 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: unixtime2tm.c,v 1.12 2005/08/03 14:06:50 sniper Exp $ */
+/* $Id: unixtime2tm.c,v 1.12.2.1 2005/12/19 13:00:37 derick Exp $ */
#include "timelib.h"
@@ -121,7 +121,6 @@
tm->sse_uptodate = 1;
tm->tim_uptodate = 1;
tm->is_localtime = 0;
- tm->have_zone = 0;
}
void timelib_update_from_sse(timelib_time *tm)
@@ -138,8 +137,6 @@
timelib_unixtime2gmt(tm, tm->sse - (tm->z * 60));
- tm->is_localtime = 1;
- tm->have_zone = 1;
tm->z = z;
tm->dst = dst;
goto cleanup;
@@ -165,25 +162,45 @@
tm->have_zone = 1;
}
-void timelib_unixtime2local(timelib_time *tm, timelib_sll ts, timelib_tzinfo*
tz)
+void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
{
timelib_time_offset *gmt_offset;
+ timelib_tzinfo *tz = tm->tz_info;
- gmt_offset = timelib_get_time_zone_info(ts, tz);
- timelib_unixtime2gmt(tm, ts + gmt_offset->offset);
+ tm->is_localtime = 1;
+ tm->have_zone = 1;
- /* we need to reset the sse here as unixtime2gmt modifies it */
- tm->sse = ts;
- tm->dst = gmt_offset->is_dst;
- tm->z = gmt_offset->offset;
- tm->tz_info = tz;
+ switch (tm->zone_type) {
+ case TIMELIB_ZONETYPE_ABBR:
+ case TIMELIB_ZONETYPE_OFFSET: {
+ int z = tm->z;
+ signed int dst = tm->dst;
+
+ timelib_unixtime2gmt(tm, ts - (tm->z * 60));
- timelib_time_tz_abbr_update(tm, gmt_offset->abbr);
- timelib_time_offset_dtor(gmt_offset);
+ tm->z = z;
+ tm->dst = dst;
+ break;
+ }
- tm->is_localtime = 1;
- tm->have_zone = 1;
- tm->zone_type = TIMELIB_ZONETYPE_ID;
+ case TIMELIB_ZONETYPE_ID:
+ gmt_offset = timelib_get_time_zone_info(ts, tz);
+ timelib_unixtime2gmt(tm, ts + gmt_offset->offset);
+
+ /* we need to reset the sse here as unixtime2gmt
modifies it */
+ tm->sse = ts;
+ tm->dst = gmt_offset->is_dst;
+ tm->z = gmt_offset->offset;
+ tm->tz_info = tz;
+
+ timelib_time_tz_abbr_update(tm, gmt_offset->abbr);
+ timelib_time_offset_dtor(gmt_offset);
+ break;
+
+ default:
+ tm->is_localtime = 0;
+ tm->have_zone = 0;
+ }
}
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz)
@@ -225,7 +242,7 @@
return -1;
}
- timelib_unixtime2local(t, t->sse, t->tz_info);
+ timelib_unixtime2local(t, t->sse);
} else {
/* Converting from local time to GMT time */
DEBUG(printf("Converting from local time to GMT time\n"););
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/date_default_timezone_get-1.phpt?r1=1.2.2.4&r2=1.2.2.5&diff_format=u
Index: php-src/ext/date/tests/date_default_timezone_get-1.phpt
diff -u php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2.2.4
php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2.2.5
--- php-src/ext/date/tests/date_default_timezone_get-1.phpt:1.2.2.4 Sun Dec
18 16:15:45 2005
+++ php-src/ext/date/tests/date_default_timezone_get-1.phpt Mon Dec 19
13:00:37 2005
@@ -9,8 +9,8 @@
echo date('e'), "\n";
?>
--EXPECTF--
-Strict Standards: date_default_timezone_get(): It is not safe to rely on the
system's timezone settings. Please use the date.timezone setting, the TZ
environment variable or the date_default_timezone_set() function. We selected
'Europe/London' for 'UTC/0.0/no DST' instead in
%sdate_default_timezone_get-1.php on line 3
-Europe/London
+Strict Standards: date_default_timezone_get(): It is not safe to rely on the
system's timezone settings. Please use the date.timezone setting, the TZ
environment variable or the date_default_timezone_set() function. We selected
'UTC' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line
3
+UTC
-Strict Standards: date(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'Europe/London' for
'UTC/0.0/no DST' instead in %sdate_default_timezone_get-1.php on line 4
-Europe/London
\ No newline at end of file
+Strict Standards: date(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no
DST' instead in %sdate_default_timezone_get-1.php on line 4
+UTC
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/date_default_timezone_set-1.phpt?r1=1.1.2.6&r2=1.1.2.7&diff_format=u
Index: php-src/ext/date/tests/date_default_timezone_set-1.phpt
diff -u php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1.2.6
php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1.2.7
--- php-src/ext/date/tests/date_default_timezone_set-1.phpt:1.1.2.6 Sun Dec
18 16:15:45 2005
+++ php-src/ext/date/tests/date_default_timezone_set-1.phpt Mon Dec 19
13:00:37 2005
@@ -18,11 +18,11 @@
echo date(DATE_ISO8601, $date4), "\n";
?>
--EXPECTF--
-Strict Standards: strtotime(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'Europe/London' for
'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 3
+Strict Standards: strtotime(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no
DST' instead in %sdate_default_timezone_set-1.php on line 3
-Strict Standards: strtotime(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'Europe/London' for
'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 4
+Strict Standards: strtotime(): It is not safe to rely on the system's timezone
settings. Please use the date.timezone setting, the TZ environment variable or
the date_default_timezone_set() function. We selected 'UTC' for 'UTC/0.0/no
DST' instead in %sdate_default_timezone_set-1.php on line 4
America/Indiana/Knox
2005-01-12T03:00:00-0500
-2005-07-12T02:00:00-0500
+2005-07-12T03:00:00-0500
2005-01-12T08:00:00-0500
2005-07-12T08:00:00-0500
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/tests/mktime-2.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/date/tests/mktime-2.phpt
diff -u php-src/ext/date/tests/mktime-2.phpt:1.1.2.1
php-src/ext/date/tests/mktime-2.phpt:1.1.2.2
--- php-src/ext/date/tests/mktime-2.phpt:1.1.2.1 Tue Aug 9 21:10:22 2005
+++ php-src/ext/date/tests/mktime-2.phpt Mon Dec 19 13:00:37 2005
@@ -3,7 +3,7 @@
--INI--
error_reporting=2047
--FILE--
-<?php /* $Id: mktime-2.phpt,v 1.1.2.1 2005/08/09 21:10:22 derick Exp $ */
+<?php
$timezones = array(
'GMT0',
'Europe/London'
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/astro.c?view=markup&rev=1.1
Index: php-src/ext/date/lib/astro.c
+++ php-src/ext/date/lib/astro.c
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| 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 |
| [EMAIL PROTECTED] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Algorithms are taken from a public domain source by Paul |
| Schlyter, who wrote this in December 1992 |
+----------------------------------------------------------------------+
| Authors: Derick Rethans <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
/* $Id: astro.c,v 1.1 2005/12/19 12:57:49 derick Exp $ */
#include <stdio.h>
#include <math.h>
#include "timelib.h"
#define days_since_2000_Jan_0(y,m,d) \
(367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
#ifndef PI
#define PI 3.1415926535897932384
#endif
#define RADEG ( 180.0 / PI )
#define DEGRAD ( PI / 180.0 )
/* The trigonometric functions in degrees */
#define sind(x) sin((x)*DEGRAD)
#define cosd(x) cos((x)*DEGRAD)
#define tand(x) tan((x)*DEGRAD)
#define atand(x) (RADEG*atan(x))
#define asind(x) (RADEG*asin(x))
#define acosd(x) (RADEG*acos(x))
#define atan2d(y,x) (RADEG*atan2(y,x))
/* Following are some macros around the "workhorse" function __daylen__ */
/* They mainly fill in the desired values for the reference altitude */
/* below the horizon, and also selects whether this altitude should */
/* refer to the Sun's center or its upper limb. */
#include "astro.h"
/******************************************************************/
/* This function reduces any angle to within the first revolution */
/* by subtracting or adding even multiples of 360.0 until the */
/* result is >= 0.0 and < 360.0 */
/******************************************************************/
#define INV360 (1.0 / 360.0)
/*****************************************/
/* Reduce angle to within 0..360 degrees */
/*****************************************/
static double astro_revolution(double x)
{
return (x - 360.0 * floor(x * INV360));
}
/*********************************************/
/* Reduce angle to within +180..+180 degrees */
/*********************************************/
static double astro_rev180( double x )
{
return (x - 360.0 * floor(x * INV360 + 0.5));
}
/*******************************************************************/
/* This function computes GMST0, the Greenwich Mean Sidereal Time */
/* at 0h UT (i.e. the sidereal time at the Greenwhich meridian at */
/* 0h UT). GMST is then the sidereal time at Greenwich at any */
/* time of the day. I've generalized GMST0 as well, and define it */
/* as: GMST0 = GMST - UT -- this allows GMST0 to be computed at */
/* other times than 0h UT as well. While this sounds somewhat */
/* contradictory, it is very practical: instead of computing */
/* GMST like: */
/* */
/* GMST = (GMST0) + UT * (366.2422/365.2422) */
/* */
/* where (GMST0) is the GMST last time UT was 0 hours, one simply */
/* computes: */
/* */
/* GMST = GMST0 + UT */
/* */
/* where GMST0 is the GMST "at 0h UT" but at the current moment! */
/* Defined in this way, GMST0 will increase with about 4 min a */
/* day. It also happens that GMST0 (in degrees, 1 hr = 15 degr) */
/* is equal to the Sun's mean longitude plus/minus 180 degrees! */
/* (if we neglect aberration, which amounts to 20 seconds of arc */
/* or 1.33 seconds of time) */
/* */
/*******************************************************************/
static double astro_GMST0(double d)
{
double sidtim0;
/* Sidtime at 0h UT = L (Sun's mean longitude) + 180.0 degr */
/* L = M + w, as defined in sunpos(). Since I'm too lazy to */
/* add these numbers, I'll let the C compiler do it for me. */
/* Any decent C compiler will add the constants at compile */
/* time, imposing no runtime or code overhead. */
sidtim0 = astro_revolution((180.0 + 356.0470 + 282.9404) +
(0.9856002585 + 4.70935E-5) * d);
return sidtim0;
}
/* This function computes the Sun's position at any instant */
/******************************************************/
/* Computes the Sun's ecliptic longitude and distance */
/* at an instant given in d, number of days since */
/* 2000 Jan 0.0. The Sun's ecliptic latitude is not */
/* computed, since it's always very near 0. */
/******************************************************/
static void astro_sunpos(double d, double *lon, double *r)
{
double M, /* Mean anomaly of the Sun */
w, /* Mean longitude of perihelion */
/* Note: Sun's mean longitude = M + w */
e, /* Eccentricity of Earth's orbit */
E, /* Eccentric anomaly */
x, y, /* x, y coordinates in orbit */
v; /* True anomaly */
/* Compute mean elements */
M = astro_revolution(356.0470 + 0.9856002585 * d);
w = 282.9404 + 4.70935E-5 * d;
e = 0.016709 - 1.151E-9 * d;
/* Compute true longitude and radius vector */
E = M + e * RADEG * sind(M) * (1.0 + e * cosd(M));
x = cosd(E) - e;
y = sqrt(1.0 - e*e) * sind(E);
*r = sqrt(x*x + y*y); /* Solar distance */
v = atan2d(y, x); /* True anomaly */
*lon = v + w; /* True solar longitude */
if (*lon >= 360.0) {
*lon -= 360.0; /* Make it 0..360 degrees */
}
}
static void astro_sun_RA_dec(double d, double *RA, double *dec, double *r)
{
double lon, obl_ecl, x, y, z;
/* Compute Sun's ecliptical coordinates */
astro_sunpos(d, &lon, r);
/* Compute ecliptic rectangular coordinates (z=0) */
x = *r * cosd(lon);
y = *r * sind(lon);
/* Compute obliquity of ecliptic (inclination of Earth's axis) */
obl_ecl = 23.4393 - 3.563E-7 * d;
/* Convert to equatorial rectangular coordinates - x is unchanged */
z = y * sind(obl_ecl);
y = y * cosd(obl_ecl);
/* Convert to spherical coordinates */
*RA = atan2d(y, x);
*dec = atan2d(z, sqrt(x*x + y*y));
}
/**
* Note: timestamp = unixtimestamp (NEEDS to be 00:00:00 UT)
* Eastern longitude positive, Western longitude negative
* Northern latitude positive, Southern latitude negative
* The longitude value IS critical in this function!
* altit = the altitude which the Sun should cross
* Set to -35/60 degrees for rise/set, -6 degrees
* for civil, -12 degrees for nautical and -18
* degrees for astronomical twilight.
* upper_limb: non-zero -> upper limb, zero -> center
* Set to non-zero (e.g. 1) when computing rise/set
* times, and to zero when computing start/end of
* twilight.
* *rise = where to store the rise time
* *set = where to store the set time
* Both times are relative to the specified altitude,
* and thus this function can be used to compute
* various twilight times, as well as rise/set times
* Return value: 0 = sun rises/sets this day, times stored at
* *trise and *tset.
* +1 = sun above the specified "horizon" 24 hours.
* *trise set to time when the sun is at south,
* minus 12 hours while *tset is set to the south
* time plus 12 hours. "Day" length = 24 hours
* -1 = sun is below the specified "horizon" 24 hours
* "Day" length = 0 hours, *trise and *tset are
* both set to the time when the sun is at south.
*
*/
int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double
lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll
*ts_rise, timelib_sll *ts_set)
{
double d, /* Days since 2000 Jan 0.0 (negative before) */
sr, /* Solar distance, astronomical units */
sRA, /* Sun's Right Ascension */
sdec, /* Sun's declination */
sradius, /* Sun's apparent radius */
t, /* Diurnal arc */
tsouth, /* Time when Sun is at south */
sidtime; /* Local sidereal time */
timelib_time *t_utc;
timelib_sll timestamp;
int rc = 0; /* Return cde from function - usually 0 */
/* Normalize time */
t_loc->h = 12;
t_loc->i = t_loc->s = 0;
timelib_update_ts(t_loc, NULL);
/* Calculate TS belonging to UTC 00:00 of the current day */
t_utc = timelib_time_ctor();
t_utc->y = t_loc->y;
t_utc->m = t_loc->m;
t_utc->d = t_loc->d;
t_utc->h = t_utc->i = t_utc->s = 0;
timelib_update_ts(t_utc, NULL);
/* Compute d of 12h local mean solar time */
timestamp = t_loc->sse;
d = timelib_ts_to_juliandate(timestamp) - lon/360.0;
/* Compute local sidereal time of this moment */
sidtime = astro_revolution(astro_GMST0(d) + 180.0 + lon);
/* Compute Sun's RA + Decl at this moment */
astro_sun_RA_dec( d, &sRA, &sdec, &sr );
/* Compute time when Sun is at south - in hours UT */
tsouth = 12.0 - astro_rev180(sidtime - sRA) / 15.0;
/* Compute the Sun's apparent radius, degrees */
sradius = 0.2666 / sr;
/* Do correction to upper limb, if necessary */
if (upper_limb) {
altit -= sradius;
}
/* Compute the diurnal arc that the Sun traverses to reach */
/* the specified altitude altit: */
{
double cost;
cost = (sind(altit) - sind(lat) * sind(sdec)) / (cosd(lat) *
cosd(sdec));
if (cost >= 1.0) {
rc = -1;
t = 0.0; /* Sun always below altit */
*ts_rise = *ts_set = t_utc->sse + (tsouth * 3600);
} else if (cost <= -1.0) {
rc = +1;
t = 12.0; /* Sun always above altit */
*ts_rise = t_loc->sse - (12 * 3600);
*ts_set = t_loc->sse + (12 * 3600);
} else {
t = acosd(cost) / 15.0; /* The diurnal arc, hours */
/* Store rise and set times - as Unix Timestamp */
*ts_rise = ((tsouth - t) * 3600) + t_utc->sse;
*ts_set = ((tsouth + t) * 3600) + t_utc->sse;
*h_rise = (tsouth - t);
*h_set = (tsouth + t);
}
}
/* Kill temporary time */
timelib_time_dtor(t_utc);
return rc;
}
double timelib_ts_to_juliandate(timelib_sll ts)
{
double tmp;
tmp = ts;
tmp /= 86400;
tmp += 2440587.5;
tmp -= 2451543;
return tmp;
}
http://cvs.php.net/viewcvs.cgi/php-src/ext/date/lib/astro.h?view=markup&rev=1.1
Index: php-src/ext/date/lib/astro.h
+++ php-src/ext/date/lib/astro.h
/* This macro computes the length of the day, from sunrise to sunset. */
/* Sunrise/set is considered to occur when the Sun's upper limb is */
/* 35 arc minutes below the horizon (this accounts for the refraction */
/* of the Earth's atmosphere). */
#define day_length(year,month,day,lon,lat) \
__daylen__( year, month, day, lon, lat, -35.0/60.0, 1 )
/* This macro computes the length of the day, including civil twilight. */
/* Civil twilight starts/ends when the Sun's center is 6 degrees below */
/* the horizon. */
#define day_civil_twilight_length(year,month,day,lon,lat) \
__daylen__( year, month, day, lon, lat, -6.0, 0 )
/* This macro computes the length of the day, incl. nautical twilight. */
/* Nautical twilight starts/ends when the Sun's center is 12 degrees */
/* below the horizon. */
#define day_nautical_twilight_length(year,month,day,lon,lat) \
__daylen__( year, month, day, lon, lat, -12.0, 0 )
/* This macro computes the length of the day, incl. astronomical twilight. */
/* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
/* below the horizon. */
#define day_astronomical_twilight_length(year,month,day,lon,lat) \
__daylen__( year, month, day, lon, lat, -18.0, 0 )
/* This macro computes times for sunrise/sunset. */
/* Sunrise/set is considered to occur when the Sun's upper limb is */
/* 35 arc minutes below the horizon (this accounts for the refraction */
/* of the Earth's atmosphere). */
#define timelib_astro_sun_rise_set(ts,lon,lat,hrise,hset,rise,set) \
timelib_astro_rise_set_altitude( ts, lon, lat, -35.0/60.0, 1, hrise,
hset, rise, set )
/* This macro computes the start and end times of civil twilight. */
/* Civil twilight starts/ends when the Sun's center is 6 degrees below */
/* the horizon. */
#define civil_twilight(ts,lon,lat,start,end) \
timelib_astro_rise_set_altitude( ts, lon, lat, -6.0, 0, start, end )
/* This macro computes the start and end times of nautical twilight. */
/* Nautical twilight starts/ends when the Sun's center is 12 degrees */
/* below the horizon. */
#define nautical_twilight(ts,lon,lat,start,end) \
timelib_astro_rise_set_altitude( ts, lon, lat, -12.0, 0, start, end )
/* This macro computes the start and end times of astronomical twilight. */
/* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
/* below the horizon. */
#define astronomical_twilight(ts,lon,lat,start,end) \
timelib_astro_rise_set_altitude( ts, lon, lat, -18.0, 0, start, end )
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php