Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70587 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29137 invoked from network); 11 Dec 2013 10:02:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2013 10:02:59 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.180 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.128.180 mail-ve0-f180.google.com Received: from [209.85.128.180] ([209.85.128.180:50431] helo=mail-ve0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 38/B0-22966-15838A25 for ; Wed, 11 Dec 2013 05:02:58 -0500 Received: by mail-ve0-f180.google.com with SMTP id jz11so5859998veb.11 for ; Wed, 11 Dec 2013 02:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=fe6oqulq6IHaSUR6JQcYR/MlV13zdBo+u+kpjmz3E6Y=; b=eDOGnEO392e2KADKxRt02ByaGznmrGRt69T2yjDVdUhM7ySruv1KdTU22svfCJKWLu WlTBGXaBmbVdG0ie1fIEv9BjBj3iHAmx56GE+KIgey0yghUh659oB/llY5Hx6HWBKG7L 9SqwfW8g2uYVZ1GhZ0DspccGYq8JIy5+DyNXy69gyjvfmsmDvl1VPB3jQT4ZI4sgZpZQ mXP9Wb9xQaWCJWwg9lRGj5MHy2K0MigvGgwaXGxyjxvoBt4iy7rQQHa6/myvxxvvykAT 3LIBp2ctXrnn8xkr4GBFG/1ztKlZvY7RU6k3OGlhOTQj58dF3/GAnFINFyqS9IGxnDXP oNJw== MIME-Version: 1.0 X-Received: by 10.58.29.37 with SMTP id g5mr205811veh.38.1386756174529; Wed, 11 Dec 2013 02:02:54 -0800 (PST) Received: by 10.58.128.33 with HTTP; Wed, 11 Dec 2013 02:02:54 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Dec 2013 18:02:54 +0800 Message-ID: To: Nikita Nefedov Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7b6786fe2c4a5f04ed3f55c2 Subject: Re: [PHP-DEV] timelib diff working wrong on with years From: tjerk.meesters@gmail.com (Tjerk Meesters) --047d7b6786fe2c4a5f04ed3f55c2 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Dec 11, 2013 at 5:38 PM, Nikita Nefedov wrote: > Hi, > > today I stumbled upon this bug, but I actually don't know should I call it > bug or is it right behavior? > > So for example lets get diff between 2013-10-25 and 2014-10-25: > var_dump((new DateTime("2013-03-25"))->diff(new DateTime("2014-03-25"))) > > We'll get one full year. > > Then if we try to get diff between 2012-03-25 and 2013-03-25 we'll also > get one year. > > But if we have 2012-03-01 and 2013-03-01 then we get 11 months and 30 days > (365 in int->days member)... > It gets interesting when you look one day around it: 2012-02-28 -> 2013-02-28 = 366 total, 1 year 2012-02-29 -> 2013-03-01 = 366 total, 1 year 2012-03-01 -> 2013-03-01 = 365 total, 11 months, 30 days 2013-03-02 -> 2013-03-02 = 365 total, 1 year > > Should we consider this as a bug or not? Seems like it; the total days is correct in all cases, but the breakdown doesn't look right. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7b6786fe2c4a5f04ed3f55c2--