Home » Date and Time » Date » Bug #677
so new methods
Details
| Submitted | 2004-02-03 21:52 UTC |
|---|---|
| From | smailling at free dot fr |
| Assigned | pajoye |
| Status | Closed |
| Package | Date |
| PHP Version | 4.3.4 |
| OS | windows 2000 |
| Roadmaps | (Not assigned) |
Comments
[2004-02-03 21:52 UTC] smailling at free dot fr
Description:
------------
I propose to chage the before and after method, to add the ability to work with '>=' and '<=' operator.
Here it is:
Reproduce code:
---------------
728c782
< function before($when)
---
> function before($when, $equal = false)
730c784,786
< if (Date::compare($this,$when) == -1) {
---
> $_compare = Date::compare($this,$when);
>
> if ($_compare == -1)
732c788,791
< } else {
---
>
> if ($equal && $_compare == 0)
> return true;
>
735d793
< }
746c804
< function after($when)
---
> function after($when, $equal = false)
748c806,808
< if (Date::compare($this,$when) == 1) {
---
> $_compare = Date::compare($this,$when);
>
> if ($_compare == 1)
750c810,813
< } else {
---
>
> if ($equal && $_compare == 0)
> return true;
>
752c815
< }
---
>
[2004-02-04 09:38 UTC] smailling at free dot fr
So, what is the deal?
Do we have to add 2 new methods (beforeOrEqual, ...) and remove the other ones (before, ...)?
I am fine with this.
[2004-02-04 16:13 UTC] baba at php dot net
we should not remove old methods, as this would break code that is using them.
if we want to implement the new methods and then have the old signatures just call the new code, that would be fine.
[2004-02-05 08:15 UTC] smailling at free dot fr
Here is the diff
728c782,797
< function before($when)
---
> function before($when, $equal = false)
> {
> return $this->beforeOrEqual($when, false);
> }
>
> /**
> * Test if this date/time is before a certain date/time
> *
> * Test if this date/time is before a certain date/time
> *
> * @access public
> * @param object Date $when the date to test against
> * @param boolean $equal Specify if the operator is < or <=
> * @return boolean true if this date is before $when
> */
> function beforeOrEqual($when, $equal = true)
730c799,801
< if (Date::compare($this,$when) == -1) {
---
> $_compare = Date::compare($this,$when);
>
> if ($_compare == -1)
732c803,806
< } else {
---
>
> if ($equal && $_compare == 0)
> return true;
>
735d808
< }
748c821,839
< if (Date::compare($this,$when) == 1) {
---
> return $this->afterOrEqual($when, false);
>
> }
>
> /**
> * Test if this date/time is after a certian date/time
> *
> * Test if this date/time is after a certian date/time
> *
> * @access public
> * @param object Date $when the date to test against
> * @param boolean $equal Specify if the operator is < or <=
> * @return boolean true if this date is after $when
> */
> function afterOrEqual($when, $equal = true)
> {
> $_compare = Date::compare($this,$when);
>
> if ($_compare == 1)
750c841,844
< } else {
---
>
> if ($equal && $_compare == 0)
> return true;
>
752c846
< }
---
>