Re: Problems with Date.php 1.3.1 beta
| From: | Chris LeCompte | Date: | Wed, 17 Sep 2003 21:36:29 +0000 |
| Subject: | Re: Problems with Date.php 1.3.1 beta | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-21663@lists.php.net to get a copy of this message | ||
>On Mon, 4 Aug 2003 15:11:57 +0200
>LIMBOURG Arnaud <arnaud.limbourg.prestataire@cegetel.fr> wrote:
>
>> > > elseif (preg_match('/\d{8}/',$date)) {
>> > > $this->setDate($date.'000000',DATE_FORMAT_TIMESTAMP);
>> > > }
>> >
>> > preg_match('/$\d{8}^/',$date) is the way. Thanks to have reported
>> > this bug.
>>
>> $ is for end of line while ^ is for beginning of line, didn't you
>> invert those two in your mail ?
>
>I did, once I did not copy/paste :)
>
>pierre
Shouldn't a check such as
function Date($date = null) {
if (is_null($date)) {
// create default Date object
} else if (is_string($date)) {
// handle timestamp/ISO formats
} else {
// handle unix timestamps
}
}
be sufficient since the two other date formats should be strings. The fix posted earlier would
cause any timestamps in the range 10000000-99999999 to be misinterpreted as timestamps rather than
as unixtimestamps. Not too big of a deal since those dates are in the 70s, but for
consistency's sake should probably be fixed.
chris