detected through the inputstring you provided.
Zend_Date is per default set to accept all sort of inputs and to fix wrong
dates automatically.
You set:
Year = 0
Month = 0 -> which is detected as January - 1 which is equal to December
Day = 0 -> which is detected as 1st Monthday - 1 which is equal to the last
day of the previous Month
Such a date is valid, as long as you accept automatical corrections.
Without corrections such a date is not valid because there is no month 0 and
no day 0.
And Zend_Date will never output a invalid date like month 0 and day 0.
Databases use such behaviour to be able to allow null dates to be outputted.
But this are no real dates.
As Zend_Date is no database driven component, it's really ISO related, it
will not allow such behaviour.
So you can:
* use Zend_Db for DB problems
* or use isDate to check if the input is a date input
* or simply check for the fixed date
* or use your database to get fixed dates as output instead of 0000...
* or store such dates simply as 1.1.1900
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "Paul Shoemaker" <paul.shoemaker@helloecho.com>
To: "Thomas Weidner" <thomas.weidner@gmx.at>
Cc: <fw-mvc@lists.zend.com>; <fw-i18n@lists.zend.com>
Sent: Wednesday, September 03, 2008 8:21 PM
Subject: Re: [fw-mvc] Zend_Date issue
> Can you please explain the logic behind how that specific date is
> chosen as the output when the invalid time stamp 0000-00-00 00:00:00
> is passed to Zend_Date?
>
> Also, I would argue that a time stamp 0000-00-00 00:00:00 is
> technically valid as this is what is output from the database in the
> event that the database admin set this value as the default on
> insert. Is there a database best practice I am missing, perhaps?
> Could there be a mechanism created whereby Zend_Date would simply
> output 0000-00-00 00:00:00 if that is passed to it? This would keep
> me from having to code this logic:
>
> if($LastLoginDate == '0000-00-00 00:00:00'){
> $lastLoginDateFinal = 'Not Recorded';
> }
> else{
> $lastLoginDateLocalized = new Zend_Date($LastLoginDate);
> $lastLoginDateFinal = $lastLoginDateLocalized->toString();
> }
>
> Paul Shoemaker | LAMP Developer
> paul.shoemaker@helloecho.com
>
> echo | Hello. Hello. | helloecho.com
>
> The information contained in this message is intended only for the use
> of the individual or entity named above. If the reader of this message
> is not the intended recipient, or the employee or agent responsible for
> delivering it to the intended recipient, you are hereby notified that
> any dissemination, distribution, or copying of this communication is
> strictly prohibited.
>
> On Sep 3, 2008, at 10:26 AM, Thomas Weidner wrote:
>
>> Have you ever heard of the month 0 ???
>> Me not, and Zend_Date also not.
>>
>> That's the reason why Zend_Date automatically fixes this wrong date.
>>
>> Greetings
>> Thomas Weidner, I18N Team Leader, Zend Framework
>> http://www.thomasweidner.com
>>
>> ----- Original Message -----
>> From: "Paul Shoemaker" <paul.shoemaker@helloecho.com>
>> To: <fw-mvc@lists.zend.com>
>> Sent: Wednesday, September 03, 2008 5:17 PM
>> Subject: [fw-mvc] Zend_Date issue
>>
>>
>> > Hello,
>> >
>> > Can anyone verify that they are experiencing this issue? When I
>> > initialized a Zend_Date object with the following:
>> >
>> > $date = new Zend_Date('0000-00-00 00:00:00');
>> >
>> > and then output the string value with:
>> >
>> > $date->toString();
>> >
>> > I receive the following output(via var_dump):
>> >
>> > string 'Nov 30, 00-1 12:00:00 AM' (length=24)
>> >
>> > Anyone know what is happening here? Here is the output from
>> var_dump
>> > of the object:
>> >
>> > object(Zend_Date)[75]
>> > private '_Locale' =>
>> > object(Zend_Locale)[72]
>> > private '_Locale' => string 'en_US' (length=5)
>> > private '_Codeset' => null
>> > private '_Fractional' => int 0
>> > private '_Precision' => int 3
>> > private '_unixTimestamp' => string '-62170135200' (length=12)
>> > private '_timezone' => string 'America/Chicago' (length=15)
>> > private '_offset' => int 21600
>> > private '_syncronised' => int 0
>> > protected '_dst' => boolean true
>> >
>> >
>> > Paul Shoemaker | LAMP Developer
>> > paul.shoemaker@helloecho.com
>> >
>> > echo | Hello. Hello. | helloecho.com
>> >
>> > The information contained in this message is intended only for the
>> use
>> > of the individual or entity named above. If the reader of this
>> message
>> > is not the intended recipient, or the employee or agent
>> responsible for
>> > delivering it to the intended recipient, you are hereby notified
>> that
>> > any dissemination, distribution, or copying of this communication is
>> > strictly prohibited.
>>
>
>
没有评论:
发表评论