error.
- Adjusted tests to use the date_timezone_set() function.
-/* Generated by re2c 0.9.8.dev on Fri Jul 1 09:16:07 2005 */
+/* Generated by re2c 0.9.8.dev on Sun Jul 3 16:51:26 2005 */
#line 1 "parse_date.re"
/*
+----------------------------------------------------------------------+
}
}
-static timelib_tz_lookup_table* zone_search(char *word, int left, int right)
+static timelib_tz_lookup_table* zone_search(const char *word, int left, int right)
{
int mid, cmp;
*/
}
+char *timelib_timezone_id_from_abbr(const char *abbr)
+{
+ timelib_tz_lookup_table *tp;
+
+ tp = zone_search(abbr, 0, sizeof(timelib_timezone_lookup) / sizeof(*timelib_timezone_lookup) - 1);
+ return (tp->full_tz_name);
+}
#ifdef DEBUG_PARSER_STUB
int main(void)
}
}
-static timelib_tz_lookup_table* zone_search(char *word, int left, int right)
+static timelib_tz_lookup_table* zone_search(const char *word, int left, int right)
{
int mid, cmp;
*/
}
+char *timelib_timezone_id_from_abbr(const char *abbr)
+{
+ timelib_tz_lookup_table *tp;
+
+ tp = zone_search(abbr, 0, sizeof(timelib_timezone_lookup) / sizeof(*timelib_timezone_lookup) - 1);
+ return (tp->full_tz_name);
+}
#ifdef DEBUG_PARSER_STUB
int main(void)
}
}
-static timelib_tz_lookup_table* zone_search(char *word, int left, int right)
+static timelib_tz_lookup_table* zone_search(const char *word, int left, int right)
{
int mid, cmp;
*/
}
+char *timelib_timezone_id_from_abbr(const char *abbr)
+{
+ timelib_tz_lookup_table *tp;
+
+ tp = zone_search(abbr, 0, sizeof(timelib_timezone_lookup) / sizeof(*timelib_timezone_lookup) - 1);
+ return (tp->full_tz_name);
+}
#ifdef DEBUG_PARSER_STUB
int main(void)
/* From parse_date.re */
timelib_time *timelib_strtotime(char *s);
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
+char *timelib_timezone_id_from_abbr(const char *abbr);
/* From tm2unixtime.c */
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
if (DATEG(default_timezone) && (strlen(DATEG(default_timezone)) > 0)) {
return DATEG(default_timezone);
}
+#if HAVE_TM_ZONE
+ /* Try to guess timezone from system information */
+ {
+ struct tm *ta, tmbuf;
+ time_t the_time;
+ char *tzid;
+
+ the_time = time(NULL);
+ ta = php_localtime_r(&the_time, &tmbuf);
+ tzid = timelib_timezone_id_from_abbr(ta->tm_zone);
+ if (! tzid) {
+ tzid = "UTC";
+ }
+
+ php_error_docref(NULL TSRMLS_CC, E_STRICT, "It is not safe to rely on the systems timezone settings, please use the date.timezone setting, the TZ environment variable or the date_timezone_set() function. We now use '%s' for '%s'", tzid, ta->tm_zone);
+ return tzid;
+ }
+#endif
/* Fallback to UTC */
return "UTC";
}
Bug #26198 (strtotime handling of "M Y" and "Y M" format)
--FILE--
<?php
- putenv("TZ=");
+ date_timezone_set("GMT");
echo gmdate("F Y (Y-m-d H:i:s T)\n", strtotime("Oct 2001"));
echo gmdate("M Y (Y-m-d H:i:s T)\n", strtotime("2001 Oct"));
?>
Bug #28599 (strtotime fails with zero base time)
--FILE--
<?php
+date_timezone_set("Europe/Amsterdam");
print gmdate("d-m-Y H:i:s", strtotime("+30 minutes", 1100535573));
?>
--EXPECT--
Bug #29585 (Support week numbers in strtotime())
--FILE--
<?php
-putenv('TZ=');
+date_timezone_set("GMT");
echo gmdate("Y-m-d H:i:s", strtotime("2004W30"));
-
?>
--EXPECT--
2004-07-19 00:00:00
Bug #29595 (Roman number format for months)
--FILE--
<?php
-
+date_timezone_set("GMT");
$from_postgres = '2004-08-09 14:48:27.304809+10';
echo strtotime($from_postgres);
-
?>
--EXPECT--
1092026907
Bug #33056 (strtotime() does not parse 20050518t090000Z)
--FILE--
<?php
+date_timezone_set("GMT");
echo strtotime('20050518t090000Z')."\n";
echo strtotime('20050518t091234Z')."\n";
echo strtotime('20050518t191234Z')."\n";
Bug #33452 (Support for year accompanying ISO week nr)
--FILE--
<?php
+date_timezone_set("GMT");
echo date('Y-W', strtotime('2005-1-1')), "\n";
echo date('o-W', strtotime('2005-1-1')), "\n";
?>
strtotime() - Format: @timestamps
--FILE--
<?php
+date_timezone_set("GMT");
$i = 5;
$max = getrandmax();