Zend Framework

would be nice to have Zend_Date::factory() method

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: None
  • Fix Version/s: 1.10.2
  • Component/s: Zend_Date
  • Labels:
    None

Description

Would be nice to have Zend_Date::factory() method, that will be identical to __construct(), but will work as static factory method. For example:

$date = new Zend_Date('10/03/2010');
echo $date->get(Zend_Date::MONTH);

Would look much nicer and compact with this:

echo Zend_Date::factory('10/03/2010')->get(Zend_Date::MONTH);

Activity

Hide
Thomas Weidner added a comment -

There is no difference to

print new Zend_Date('10/03/2010')->get(Zend_Date::MONTH);

As you can have multiple instances of this object the factory pattern is not necessary.

Show
Thomas Weidner added a comment - There is no difference to
print new Zend_Date('10/03/2010')->get(Zend_Date::MONTH);
As you can have multiple instances of this object the factory pattern is not necessary.
Hide
Yegor Bugayenko added a comment -

such syntax is not allowed in PHP

Show
Yegor Bugayenko added a comment - such syntax is not allowed in PHP
Hide
Yegor Bugayenko added a comment -

maybe a parameter to now() would help? for example:

echo Zend_Date::now('10/03/2010')->get(Zend_Date::MONTH);

what do you think?

Show
Yegor Bugayenko added a comment - maybe a parameter to now() would help? for example: echo Zend_Date::now('10/03/2010')->get(Zend_Date::MONTH); what do you think?
Hide
Raphael Dehousse added a comment -

I would rather prefer the factory method then.
Because, for me, now will return the current Zend_Date, and I won't think that I would pass a param to now() to receive another date.
And also, the factory method could have all the params of Zend_Date constructor.

Like that, we could do

Zend_Date::factory('2010/01/01', 'yyyy/dd/MM', $locale)->get(Zend_Date::MONTH);

etc

My 2 cents,

Show
Raphael Dehousse added a comment - I would rather prefer the factory method then. Because, for me, now will return the current Zend_Date, and I won't think that I would pass a param to now() to receive another date. And also, the factory method could have all the params of Zend_Date constructor. Like that, we could do Zend_Date::factory('2010/01/01', 'yyyy/dd/MM', $locale)->get(Zend_Date::MONTH); etc My 2 cents,
Hide
Thomas Weidner added a comment -

I still see no reason to add what's already working into a class which will be completly changed in the next release.

Actually it simply works with:

echo Zend_Date::now()>set('2010/01/01', 'yyyy/dd/MM', $locale)>get(Zend_Date::MONTH);

Show
Thomas Weidner added a comment - I still see no reason to add what's already working into a class which will be completly changed in the next release. Actually it simply works with: echo Zend_Date::now()>set('2010/01/01', 'yyyy/dd/MM', $locale)>get(Zend_Date::MONTH);
Hide
Thomas Weidner added a comment -

Additionally a date filter is already accepted and will be added with the next minor release which itself simplifies the handling much more.

Show
Thomas Weidner added a comment - Additionally a date filter is already accepted and will be added with the next minor release which itself simplifies the handling much more.
Hide
Yegor Bugayenko added a comment - - edited

How exactly I can create an object and get its string value in one command? Could you please give a code example? Thanks.

Show
Yegor Bugayenko added a comment - - edited How exactly I can create an object and get its string value in one command? Could you please give a code example? Thanks.
Hide
Yegor Bugayenko added a comment -

sorry, I missed your comment

Show
Yegor Bugayenko added a comment - sorry, I missed your comment

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: