pingjiang / datejs

Automatically exported from code.google.com/p/datejs
Other
0 stars 0 forks source link

isAfter() and isBefore not included in library #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. Create a date, like Date.today()
2. Create a second date, like Date.today().add(1)
3. Attempt to perform date1.isAfter(date2) or date1.isBefore(date2)

The expected output is that the isAfter and isBefore methods return a 
boolean. Instead, the methods are not found.

Alpha1 version.

Sorry if I missed it somewhere...is it known that this is not implemented?

Original issue reported on code.google.com by ape...@gmail.com on 9 Jun 2009 at 5:27

GoogleCodeExporter commented 9 years ago
I am also having this problem.

Original comment by Tom.Tres...@gmail.com on 23 Jun 2009 at 8:57

GoogleCodeExporter commented 9 years ago
I attempted this as well in my code that has logic that looks for start dates 
before
3pm.  I got an XML error when I tried to use the newer file (from 2008)

Code sample:

function dateCheck(checkDate) // I use a date validator before I send date as 
String
{
  var refDate = Date.parse(checkDate);
  var today3pm = Date.today().set({ hour: 15, minute: 0, second: 0});

  if(refDate.isBefore(today3pm)) // error detected using Firebug
  { // logic here  }

  if(refDate.isAfter(today3pm)) // error detected using Firebug
  { // logic here  }

  if(refDate.compareTo(today3pm) < 0) // this is how I worked around it
  { // logic here  }
}

Original comment by javase...@gmail.com on 13 Jul 2009 at 2:17

GoogleCodeExporter commented 9 years ago
Just ensure you are using the latest code from svn 
(http://www.datejs.com/svn/). The
.isBefore and .isAfter functions were added after the Alpha-1 release. 

The following test appears to work correctly when using the svn code base.

Example

var d1 = Date.today();
var d2 = Date.today().add(1).day();

console.log(d1.isAfter(d2)); // false
console.log(d1.isBefore(d2)); // true

Original comment by geoff%co...@gtempaccount.com on 13 Jul 2009 at 6:39