Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-DEV] Solution to date issue in 5.1 [RSS Feed]

#1 Nov. 26, 2005 04:50:42

Ilia A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


The attached patch is a possible solution to the date *crisis*, it
renames the class to PhpDate to avoid any namespace conflicts with pear
or custom user classes called date.

If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
else) goes out on Monday.

IliaIndex: ext/date/php_date.c
===================================================================
RCS file: /repository/php-src/ext/date/php_date.c,v
retrieving revision 1.43.2.22
diff -u -p -a -d -r1.43.2.22 php_date.c
--- ext/date/php_date.c 20 Nov 2005 20:14:23 -0000 1.43.2.22
+++ ext/date/php_date.c 26 Nov 2005 04:47:25 -0000
@@ -1006,7 +1006,7 @@ static void date_register_classes(TSRMLS
{
zend_class_entry ce_date, ce_timezone;

- INIT_CLASS_ENTRY(ce_date, "date", date_funcs_date);
+ INIT_CLASS_ENTRY(ce_date, "PhpDate", date_funcs_date);
ce_date.create_object = date_object_new_date;
date_ce_date = zend_register_internal_class_ex(&ce_date, NULL, NULL
TSRMLS_CC);
memcpy(&date_object_handlers_date, zend_get_std_object_handlers(),
sizeof(zend_object_handlers));
Index: ext/date/tests/bug33869.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/bug33869.phpt,v
retrieving revision 1.2.2.1
diff -u -p -a -d -r1.2.2.1 bug33869.phpt
--- ext/date/tests/bug33869.phpt 17 Nov 2005 21:05:30 -0000 1.2.2.1
+++ ext/date/tests/bug33869.phpt 26 Nov 2005 04:47:25 -0000
@@ -4,17 +4,17 @@ Bug #33869 (strtotime() doesn't parse "+
<?php
date_default_timezone_set("UTC");
$tm = strtotime("2005-01-01 01:01:01");
- echo date(date::ISO8601, strtotime('+5days', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+5days', $tm));
echo "\n";
- echo date(date::ISO8601, strtotime('+1month', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+1month', $tm));
echo "\n";
- echo date(date::ISO8601, strtotime('+1year', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+1year', $tm));
echo "\n";
- echo date(date::ISO8601, strtotime('+5 days', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+5 days', $tm));
echo "\n";
- echo date(date::ISO8601, strtotime('+1 month', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+1 month', $tm));
echo "\n";
- echo date(date::ISO8601, strtotime('+1 year', $tm));
+ echo date(PhpDate::ISO8601, strtotime('+1 year', $tm));
echo "\n";
?>
--EXPECT--
Index: ext/date/tests/bug34087.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/bug34087.phpt,v
retrieving revision 1.1.2.3
diff -u -p -a -d -r1.1.2.3 bug34087.phpt
--- ext/date/tests/bug34087.phpt 17 Nov 2005 21:05:30 -0000 1.1.2.3
+++ ext/date/tests/bug34087.phpt 26 Nov 2005 04:47:25 -0000
@@ -6,10 +6,10 @@ date_default_timezone_set("UTC");
echo "Y/m/d: ", strtotime("2005/8/12"), "\n";
echo "Y-m-d: ", strtotime("2005-8-12"), "\n";

-echo date(date::ISO8601, strtotime("2005/1/2")), "\n";
-echo date(date::ISO8601, strtotime("2005/01/02")), "\n";
-echo date(date::ISO8601, strtotime("2005/01/2")), "\n";
-echo date(date::ISO8601, strtotime("2005/1/02")), "\n";
+echo date(PhpDate::ISO8601, strtotime("2005/1/2")), "\n";
+echo date(PhpDate::ISO8601, strtotime("2005/01/02")), "\n";
+echo date(PhpDate::ISO8601, strtotime("2005/01/2")), "\n";
+echo date(PhpDate::ISO8601, strtotime("2005/1/02")), "\n";
?>
--EXPECT--
Y/m/d: 1123804800
Index: ext/date/tests/bug34676.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/bug34676.phpt,v
retrieving revision 1.1.2.3
diff -u -p -a -d -r1.1.2.3 bug34676.phpt
--- ext/date/tests/bug34676.phpt 17 Nov 2005 21:05:30 -0000 1.1.2.3
+++ ext/date/tests/bug34676.phpt 26 Nov 2005 04:47:25 -0000
@@ -10,7 +10,7 @@ $tests = array(

foreach ($tests as $test) {
$t = strtotime("2005-12-22 ". $test);
- printf("%-10s => %s\n", $test, date(date::ISO8601, $t));
+ printf("%-10s => %s\n", $test, date(PhpDate::ISO8601, $t));
}

?>
Index: ext/date/tests/bug34771.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/bug34771.phpt,v
retrieving revision 1.1.2.3
diff -u -p -a -d -r1.1.2.3 bug34771.phpt
--- ext/date/tests/bug34771.phpt 17 Nov 2005 21:05:30 -0000 1.1.2.3
+++ ext/date/tests/bug34771.phpt 26 Nov 2005 04:47:25 -0000
@@ -13,7 +13,7 @@ $tests = array(

foreach ($tests as $test) {
$t = strtotime("2005-12-22 ". $test);
- printf("%-10s => %s\n", $test, date(date::ISO8601, $t));
+ printf("%-10s => %s\n", $test, date(PhpDate::ISO8601, $t));
}

?>
Index: ext/date/tests/date_default_timezone_set-1.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/date_default_timezone_set-1.phpt,v
retrieving revision 1.1.2.3
diff -u -p -a -d -r1.1.2.3 date_default_timezone_set-1.phpt
--- ext/date/tests/date_default_timezone_set-1.phpt 17 Nov 2005 21:05:30
-0000 1.1.2.3
+++ ext/date/tests/date_default_timezone_set-1.phpt 26 Nov 2005 04:47:25
-0000
@@ -12,10 +12,10 @@ date.timezone=
$date4 = strtotime("2005-07-12 08:00:00");

echo date_default_timezone_get(), "\n";
- echo date(date::ISO8601, $date1), "\n";
- echo date(date::ISO8601, $date2), "\n";
- echo date(date::ISO8601, $date3), "\n";
- echo date(date::ISO8601, $date4), "\n";
+ echo date(PhpDate::ISO8601, $date1), "\n";
+ echo date(PhpDate::ISO8601, $date2), "\n";
+ echo date(PhpDate::ISO8601, $date3), "\n";
+ echo date(PhpDate::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
Index: ext/date/tests/mktime-3.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/mktime-3.phpt,v
retrieving revision 1.1.2.1
diff -u -p -a -d -r1.1.2.1 mktime-3.phpt
--- ext/date/tests/mktime-3.phpt 17 Nov 2005 21:05:30 -0000 1.1.2.1
+++ ext/date/tests/mktime-3.phpt 26 Nov 2005 04:47:25 -0000
@@ -16,7 +16,7 @@ foreach ($tzs as $tz) {
if ($ret == FALSE) {
echo "out of range\n";
} else {
- echo date("F ".date::ISO8601, $ret), "\n";
+ echo date("F ".PhpDate::ISO8601, $ret), "\n";
}
}
echo "\n";
Index: ext/date/tests/strtotime.phpt
===================================================================
RCS file: /repository/php-src/ext/date/tests/strtotime.phpt,v
retrieving revision 1.1.2.1
diff -u -p -a -d -r1.1.2.1 strtotime.phpt
--- ext/date/tests/strtotime.phpt 17 Nov 2005 21:05:30 -0000 1.1.2.1
+++ ext/date/tests/strtotime.phpt 26 Nov 2005 04:47:25 -0000
@@ -8,7 +8,7 @@ $d = strtotime("2005-07-14 22:30:41");
$d = strtotime("2005-07-14 22:30:41 GMT");

foreach($d as $date) {
- echo date(date::ISO8601, $date), "\n";
+ echo date(PhpDate::ISO8601, $date), "\n";
}
?>
--EXPECT----
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 Nov. 26, 2005 05:39:42

Andrei Z.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


I have to ask: what does renaming really buy us? The only purpose ofintroducing this class in RC6, as far as I can tell, was to reserve the'Date' name for future use. Since this goal is clearly unachievable,what is the point of keeping a barely functional class around (asPhpDate)? In my opinion, we should remove it (#ifdef it out), and waituntil we are ready for the full implementation and can pick a goodname, or until we have namespaces and can use them to separate PHP'sown classes.- Andrei

On Nov 25, 2005, at 8:50 PM, Ilia Alshanetsky wrote:The attached patch is a possible solution to the date *crisis*, it
renames the class to PhpDate to avoid any namespace conflicts with pear
or custom user classes called date.

If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
else) goes out on Monday.--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 Nov. 26, 2005 05:48:08

Bob S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


I object your honor!

This will set the stage for any other core objects to follow the same
convention. If namespaces are in PHPs future, design wise it would make more
sense to have them in a namespace ("PHP" seems to be popular), but if this
is released now as PhpDate, moving it to a namespace won't happen because of
BC reasons. What is so pressing in this Date class (that we've never had
until a few days ago) that it can't wait for a more thought-out
discussion/decision regarding a major shift in internal development in
regards to wrapping core functionality with object interfaces?

-1 on PhpDate
+1 on ifdef'ing it

On a side note, looking at your patch, there also seems to be no set
guidelines for class naming within core. The original class name was "date",
whereas your fix was "PhpDate, "d" vs. "P". Just another indication to me
that more things need to be worked out before the first core class is
"officially" released.

Bob Silva


> -----Original Message-----
> From: Ilia Alshanetsky
> Sent: Friday, November 25, 2005 8:50 PM
> To: intern***@*ists.php.net
> Subject: Solution to date issue in 5.1
>
> The attached patch is a possible solution to the date *crisis*, it
> renames the class to PhpDate to avoid any namespace conflicts with pear
> or custom user classes called date.
>
> If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
> else) goes out on Monday.
>
> Ilia

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#4 Nov. 26, 2005 06:10:17

Rasmus L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


Ilia Alshanetsky wrote:The attached patch is a possible solution to the date *crisis*, it
renames the class to PhpDate to avoid any namespace conflicts with pear
or custom user classes called date.

If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
else) goes out on Monday.I don't think choosing a precedent for a class naming convention shouldbe done under duress like this. I say just ifdef it back out then andput those constants back as they were before. This class doesn't buy usanything. It's just a forward-looking thing that really shouldn't go inunless we can all agree on what it is we are looking forward at.-Rasmus

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#5 Nov. 26, 2005 11:06:35

Lester C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


Rasmus Lerdorf wrote:Ilia Alshanetsky wrote:The attached patch is a possible solution to the date *crisis*, it
renames the class to PhpDate to avoid any namespace conflicts with pear
or custom user classes called date.

If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
else) goes out on Monday.I don't think choosing a precedent for a class naming convention shouldbe done under duress like this. I say just ifdef it back out then andput those constants back as they were before. This class doesn't buy usanything. It's just a forward-looking thing that really shouldn't go inunless we can all agree on what it is we are looking forward at.I strikes me that there is a more subtle problem here which goes beyondjust renaming Date, since we have had a period where people ARE buildingtheir own libraries with their own classes. So while the current niggleis Date, any new core class can potentially cause a problem. Before wehave any movement forward, a agreed method of ring fencing core classeshas to be sorted out since this was not implemented previously?--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
Treasurer - Firebird Foundation Inc.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#6 Nov. 26, 2005 12:52:29

Jani T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


So you're also for letting PEAR dictate what PHP has and not the other
way around? Somehow this doesn't sound right.

--Jani

On Fri, 25 Nov 2005, Andrei Zmievski wrote:I have to ask: what does renaming really buy us? The only purpose ofintroducing this class in RC6, as far as I can tell, was to reserve the 'Date'name for future use. Since this goal is clearly unachievable, what is thepoint of keeping a barely functional class around (as PhpDate)? In my opinion,we should remove it (#ifdef it out), and wait until we are ready for the fullimplementation and can pick a good name, or until we have namespaces and canuse them to separate PHP's own classes.- Andrei

On Nov 25, 2005, at 8:50 PM, Ilia Alshanetsky wrote:The attached patch is a possible solution to the date *crisis*, it
renames the class to PhpDate to avoid any namespace conflicts with pear
or custom user classes called date.

If there are no strong objection 5.1.1 (5.1.0 + this patch and nothing
else) goes out on Monday.--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#7 Nov. 26, 2005 12:57:15

Pierre J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


On 11/26/05, Jani Taskinen <> wrote:
>
> So you're also for letting PEAR dictate what PHP has and not the other
> way around? Somehow this doesn't sound right.

No, I do not let Derick decided on his own what should be commited in
a last RC. I do not let Derick decides what is good for me (c) or not.
This class was added "just because people asked" at some point and
was inside #ifdef for a very good reason, this code does not get any
agreement, is not stable (see the trivial fix from Tony today).

This ext/date problem is something I will hate to see happen again.
Not because I also work on that, it is not the 1st time that my
proposals are ignored, but because Derick thinks he can do what he
wants and when he wants, as a PHP QA member, I find this attitude
pathetic.

--Pierre

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#8 Nov. 26, 2005 13:08:08

Jani T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


On Sat, 26 Nov 2005, Pierre Joye wrote:This ext/date problem is something I will hate to see happen again.Well, it's totally your own fault. I remember the couple of times
you were asked to commit your stuff but you had some other things
to do. Now that someone did the work, you start flaming him.

Ever heard about the magic omelette? (the one that existed without
breaking some eggs.. :)

--Jani

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#9 Nov. 26, 2005 13:13:01

P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


On Sat, 26 Nov 2005 15:07:15 +0200 (EET)
(Jani Taskinen) wrote:

> On Sat, 26 Nov 2005, Pierre Joye wrote:
>
> > This ext/date problem is something I will hate to see happen again.
>
> Well, it's totally your own fault. I remember the couple of times
> you were asked to commit your stuff but you had some other things
> to do. Now that someone did the work, you start flaming him.

Do not lie, I was never requested to commit but you joking about the
"first commit wins" rule.



--Pierre

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#10 Nov. 26, 2005 13:27:18

Sebastian K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] Solution to date issue in 5.1


On 11/26/05, Jani Taskinen <> wrote:
>
> So you're also for letting PEAR dictate what PHP has and not the other
> way around? Somehow this doesn't sound right.

This is not about PEAR dictating, and the PEAR developers are not
those who would suffer from this PHP date class in the first place,
but every user of PHP and PEAR::Date as well as every PHP developer
who ever named a class Date.

The problem is only more obvious because there is a popular PEAR class
with this name.

As a side note: There was a time when I thought PEAR was kind of an
official PHP class library. You're almost implying that everyone who
has ever used PEAR classes is just stupid.

I think if PHP claims to have the right to introduce new standard
classes with very common names, there should at least be a list of
reserved class names and a notice about that fact (Know that was
proposed yesterday on this list). Better would be namespaces or a PHP_
class prefix, of course.

Regards,
Sebastian

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

  • Root
  • » PHP
  • » [PHP-DEV] Solution to date issue in 5.1 [RSS Feed]

Board footer

Moderator control

Enjoy the 22nd of January
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support