Packageorg.as3coreaddendum.system.comparators
Classpublic class DateComparator
InheritanceDateComparator Inheritance Object
Implements IComparator

A comparator for Date objects.

View the examples



Public Methods
 MethodDefined By
  
Constructor, creates a new StringComparator object.
DateComparator
  
compare(o1:*, o2:*):int
Performs the comparison between the two arguments.
DateComparator
Constructor Detail
DateComparator()Constructor
public function DateComparator()

Constructor, creates a new StringComparator object.

Method Detail
compare()method
public function compare(o1:*, o2:*):int

Performs the comparison between the two arguments.

Parameters

o1:* — The first Date object to be compared.
 
o2:* — The second Date object to be compared.

Returns
int — A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Throws
ArgumentError — if any of the arguments is not of type Date.
Examples
     import org.as3coreaddendum.system.comparators.DateComparator;
     
     var c:DateComparator = new DateComparator();
     
     var d1:Date = new Date(2010, 04, 09);
     var d2:Date = new Date(2010, 04, 10);
     var d3:Date = new Date(2009, 04, 10);
     var d4:Date = new Date(1980, 01, 15);
     
     c.compare(d1, d1)    // 0
     c.compare(d1, d2)    // -1
     c.compare(d2, d1)    // 1
     c.compare(d2, d3)    // 1
     c.compare(d3, d2)    // -1
     c.compare(d1, d4)    // 1
     c.compare(d4, d1)    // -1