Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64220 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69667 invoked from network); 10 Dec 2012 12:23:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Dec 2012 12:23:05 -0000 Authentication-Results: pb1.pair.com header.from=sebastian.krebs.berlin@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.170 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.215.170 mail-ea0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:44617] helo=mail-ea0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/D1-60401-824D5C05 for ; Mon, 10 Dec 2012 07:23:05 -0500 Received: by mail-ea0-f170.google.com with SMTP id d11so1124985eaa.29 for ; Mon, 10 Dec 2012 04:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=gJDAqbEtvewiermY5+Cp39wfgs1M7PVaqnfq/DsWoK8=; b=SIiuFdKv67IJ7KRValPfklCH9x+hSQ2SzOE0xs87xsJQ7zF7GsxFJhNJztQUXBDSPD 0vMgK5boN+j/LMWjpB6zZy0mv4IAAfIrxdJO/jYjzKp634awTDcDkrPHojhh+cltZjTD VgQOTzAgrqfjPqxKU7sWWNWmysABrXcPStxnvTHhECLdgrIUFxjZeBGXXuWu9amq4e3n tPyl0qMC1VA5rPgZ2bepBd56QqYSiASvzut2tUgpp16Rp815J7kgOtm5TI0PWls/6caL 2d/oqE0sDpU5ezooJ1dFmSNJyaL7psZs0HSEHH1WuwA9L4b6iq89NihoQq2TVHI/qUXs wscg== MIME-Version: 1.0 Received: by 10.14.173.65 with SMTP id u41mr49049321eel.13.1355142181981; Mon, 10 Dec 2012 04:23:01 -0800 (PST) Sender: sebastian.krebs.berlin@gmail.com X-Google-Sender-Delegation: sebastian.krebs.berlin@gmail.com Received: by 10.14.48.4 with HTTP; Mon, 10 Dec 2012 04:23:01 -0800 (PST) In-Reply-To: <4ED7146272E04A47B986ED49E771E347BB362B68DE@Ikarus.ameusgmbh.intern> References: <4ED7146272E04A47B986ED49E771E347BB362B68DE@Ikarus.ameusgmbh.intern> Date: Mon, 10 Dec 2012 13:23:01 +0100 X-Google-Sender-Auth: Io1IyhDZ3pJ3YYbQK0jkwYVHAhQ Message-ID: To: PHP internals list Content-Type: multipart/alternative; boundary=047d7b6226b0608cf704d07ea0f4 Subject: Re: [PHP-DEV] Improve DateTime Class From: krebs.seb@gmail.com (Sebastian Krebs) --047d7b6226b0608cf704d07ea0f4 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi, are you mabe just looking for $date->add(new DateInterval('P15D')); ? 2012/12/10 Christian Stoller > Hi internals, > > what do you think about improving the modification functionality of the > DateTime class. I always get a cold shiver, when I write something like > this: > $date =3D new DateTime() > $date->modify(=91+15 day=92); > > In my opinion it would be nicer if one could write: > $date->modify(15, DateTime::INTERVAL_DAY); // for adding 15 days > $date->modify(-15, DateTime::INTERVAL_DAY); // for subtracting 15 days > > Even better would be to have methods like addDays(), addMonths(), etc. > > This would make it cleaner and more readable. You do not have to do > something like this: > > $date =3D new DateTime(); > $date->modify(getDaysToAddMethod() . " day"); // I am not sure if a '+' > sign is needed if the value is positive > > And it is fully backward compatible. > > Best regards > Christian > > --=20 github.com/KingCrunch --047d7b6226b0608cf704d07ea0f4--