Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40732 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36486 invoked from network); 27 Sep 2008 08:27:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Sep 2008 08:27:03 -0000 Authentication-Results: pb1.pair.com header.from=ilia.cheishvili@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ilia.cheishvili@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.44.29 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ilia.cheishvili@gmail.com X-Host-Fingerprint: 74.125.44.29 yx-out-2324.google.com Received: from [74.125.44.29] ([74.125.44.29:17666] helo=yx-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CF/F0-30545-55EEDD84 for ; Sat, 27 Sep 2008 04:27:02 -0400 Received: by yx-out-2324.google.com with SMTP id 3so228818yxj.83 for ; Sat, 27 Sep 2008 01:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=Un2tbHvHiK3RfGv3Wo2O59QVQhAqqguTgnrumshT8YM=; b=QQx6Fh4A4PqFUha44dpitwkj5luHw1IggyEDi/QwQul+fHmy/2HVEXvGqVa9nX+5v6 O198EsvzWfvfaxrlnrrVKACyPm4sZRKYWaUS0uqBwpqM8R9atEvoDMG0+cIVy6ElMT6P DoFLyCW3bhxy+m2WLn6NGhm0APSw81cracEis= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=SSZu1VaJ6uk41mhkIjhj2qCf3gWTxcyiU0EyvRpz0ox6ovIyO2iaESboULXV9w4LSz GNQQ4McfiyrOyo9KP/cP/4cObbY9fw+b+Ejz9ZqflU2AyGmSWwgyo3kLQWvJjh25zfcr Q3yy599r/v9hRzbryOVgabO+m2DtihucEYNVA= Received: by 10.151.112.4 with SMTP id p4mr3585574ybm.73.1222504018305; Sat, 27 Sep 2008 01:26:58 -0700 (PDT) Received: by 10.151.144.11 with HTTP; Sat, 27 Sep 2008 01:26:58 -0700 (PDT) Message-ID: Date: Sat, 27 Sep 2008 02:26:58 -0600 To: "Alexey Zakhlestin" Cc: "PHP internals" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_18598_12049311.1222504018256" References: Subject: Re: [PHP-DEV] [PATCH] Fix date() bug From: ilia.cheishvili@gmail.com ("Ilia Cheishvili") ------=_Part_18598_12049311.1222504018256 Content-Type: multipart/alternative; boundary="----=_Part_18599_3461032.1222504018257" ------=_Part_18599_3461032.1222504018257 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Ah, I see. I like that even better :) And I attached yet another patch that incorporates your idea. Ilia On Sat, Sep 27, 2008 at 2:20 AM, Alexey Zakhlestin wrote: > On Sat, Sep 27, 2008 at 12:04 PM, Ilia Cheishvili > wrote: > > It definitely would be, and that's actually the way I would have > preferred > > to do it. I didn't want to impact too much code, if that makes sense in > > this case, but I'm glad that someone agrees :) > > I have attached a patch to do exactly this. > > I was thinking other in another direction.. > > case 'u': > #ifdef HAVE_GETTIMEOFDAY > gettimeofday(&tp, &tz); > length = slprintf(buffer, 32, "%06d", (int) tp.tv_usec); > #else > length = slprintf(buffer, 32, "%06d", (int) floor(t->f * 1000000)); > #endif > break; > > > > > > On Sat, Sep 27, 2008 at 1:40 AM, Alexey Zakhlestin > > wrote: > >> > >> On Sat, Sep 27, 2008 at 11:04 AM, Ilia Cheishvili > >> wrote: > >> > Hi all, > >> > This patch addresses the issue with the date() function. When passing > >> > in a > >> > 'u', the date() function simply outputs six zeros. To fix this, I > added > >> > a > >> > gettimeofday() call that figures out what to display for microseconds. > >> > I am > >> > including the headers and using the function with pre-processor > >> > safeguards > >> > as well. > >> > Take a look :) > >> > >> Wouldn't it be better, to make gettimeofday() call only in case of 'u'? > >> > >> > >> -- > >> Alexey Zakhlestin > >> http://blog.milkfarmsoft.com/ > > > > > > > > -- > Alexey Zakhlestin > http://blog.milkfarmsoft.com/ > ------=_Part_18599_3461032.1222504018257 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Ah, I see.  I like that even better :)

And I attached yet another patch that incorporates your idea.

Ilia

On Sat, Sep 27, 2008 at 2:20 AM, Alexey Zakhlestin <indeyets@gmail.com> wrote:
On Sat, Sep 27, 2008 at 12:04 PM, Ilia Cheishvili
> It definitely would be, and that's actually the way I would have preferred
> to do it.  I didn't want to impact too much code, if that makes sense in
> this case, but I'm glad that someone agrees :)
> I have attached a patch to do exactly this.

I was thinking other in another direction..

case 'u':
#ifdef HAVE_GETTIMEOFDAY
   gettimeofday(&tp, &tz);
   length = slprintf(buffer, 32, "%06d", (int) tp.tv_usec);
#else
   length = slprintf(buffer, 32, "%06d", (int) floor(t->f * 1000000));
#endif
   break;


>
> On Sat, Sep 27, 2008 at 1:40 AM, Alexey Zakhlestin <indeyets@gmail.com>
> wrote:
>>
>> On Sat, Sep 27, 2008 at 11:04 AM, Ilia Cheishvili
>> <ilia.cheishvili@gmail.com> wrote:
>> > Hi all,
>> > This patch addresses the issue with the date() function.  When passing
>> > in a
>> > 'u', the date() function simply outputs six zeros.  To fix this, I added
>> > a
>> > gettimeofday() call that figures out what to display for microseconds.
>> >  I am
>> > including the headers and using the function with pre-processor
>> > safeguards
>> > as well.
>> > Take a look :)
>>
>> Wouldn't it be better, to make gettimeofday() call only in case of 'u'?
>>
>>
>> --
>> Alexey Zakhlestin
>> http://blog.milkfarmsoft.com/
>
>



--

------=_Part_18599_3461032.1222504018257-- ------=_Part_18598_12049311.1222504018256 Content-Type: text/plain; name=date-u-fix-diff.txt Content-Transfer-Encoding: base64 X-Attachment-Id: f_fllzbkz00 Content-Disposition: attachment; filename=date-u-fix-diff.txt SW5kZXg6IHBocF9kYXRlLmgKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL3JlcG9zaXRvcnkvcGhwLXNy Yy9leHQvZGF0ZS9waHBfZGF0ZS5oLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjE3LjIuMTEuMi4z LjIuOQpkaWZmIC11IC1iIC1yMS4xNy4yLjExLjIuMy4yLjkgcGhwX2RhdGUuaAotLS0gcGhwX2Rh dGUuaAkxOCBKdWwgMjAwOCAxNDozMzo1MyAtMDAwMAkxLjE3LjIuMTEuMi4zLjIuOQorKysgcGhw X2RhdGUuaAkyNyBTZXAgMjAwOCAwODoyNTowMiAtMDAwMApAQCAtMTI4LDQgKzEyOCw2IEBACiBQ SFBBUEkgdm9pZCBwaHBfZGF0ZV9zZXRfdHpkYih0aW1lbGliX3R6ZGIgKnR6ZGIpOwogUEhQQVBJ IHRpbWVsaWJfdHppbmZvICpnZXRfdGltZXpvbmVfaW5mbyhUU1JNTFNfRCk7CiAKKyNkZWZpbmUg TUlDUk9TRUNPTkRTX1BFUl9TRUNPTkQgMTAwMDAwMAorCiAjZW5kaWYgLyogUEhQX0RBVEVfSCAq LwpJbmRleDogcGhwX2RhdGUuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvcmVwb3NpdG9yeS9waHAt c3JjL2V4dC9kYXRlL3BocF9kYXRlLmMsdgpyZXRyaWV2aW5nIHJldmlzaW9uIDEuNDMuMi40NS4y LjUxLjIuNTQKZGlmZiAtdSAtYiAtcjEuNDMuMi40NS4yLjUxLjIuNTQgcGh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