Packagevegas.util.comparators
Classpublic class DateComparator
InheritanceDateComparator Inheritance CoreObject
ImplementsICloneable, IComparator, ICopyable

This comparator compare Date objects.

Example :

   import vegas.util.comparators.DateComparator;
  
   var comp:DateComparator = new DateComparator() ;
   
   var d1:Date   = new Date(2007, 1, 1) ;
   var d2:Number =  1170284400000 ;
  var d3:Date   = new Date(2007, 2, 2) ;
   var d4:Number = 1172790000000 ;
   
  trace( comp.compare(d1, d1) ) ; // 0
  trace( comp.compare(d1, d2) ) ; // 0
  trace( comp.compare(d2, d1) ) ; // 0
  trace( comp.compare(d1, d3) ) ; // -1
  trace( comp.compare(d1, d4) ) ; // -1
  trace( comp.compare(d3, d1) ) ; // 1
  trace( comp.compare(d4, d1) ) ; // 1
   



Public Methods
 MethodDefined by
  
Creates a new DateComparator instance.
DateComparator
  
clone():*
Creates and returns a shallow copy of the object.
DateComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two Date objects.
DateComparator
  
copy():*
Creates and returns a deep copy of the object.
DateComparator
  
[static] Returns the singleton instance of a DateComparator.
DateComparator
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreObject
 Inherited
hashCode():uint
Returns a hashcode value for the object.
CoreObject
 Inherited
setLogger(log:ILogger = null):void
Sets the internal ILogger reference of this ILogable object.
CoreObject
 Inherited
toSource(indent:int = 0):String
Returns the string representation the source code of the object.
CoreObject
 Inherited
toString():String
Returns the string representation of this instance.
CoreObject
Constructor detail
DateComparator()constructor
public function DateComparator()

Creates a new DateComparator instance.

Method detail
clone()method
public function clone():*

Creates and returns a shallow copy of the object.

Returns
* — A new object that is a shallow copy of this instance.
compare()method 
public function compare(o1:*, o2:*):int

Returns an integer value to compare two Date objects.

Parameters
o1:* — the first Date object to compare.
 
o2:* — the second Date object to compare.

Returns
int

  • -1 if o1 is "lower" than (less than, before, etc.) o2 ;
  • 1 if o1 is "higher" than (greater than, after, etc.) o2 ;
  • 0 if o1 and o2 are equal.

  • Throws
    — if compare(a, b) and 'a' and 'b' must be Date or uint objects.
    copy()method 
    public function copy():*

    Creates and returns a deep copy of the object.

    Returns
    * — A new object that is a deep copy of this instance.
    getInstance()method 
    public static function getInstance():DateComparator

    Returns the singleton instance of a DateComparator. Developers are encouraged to use the comparator returned from this method instead of constructing a new instance to reduce allocation and GC overhead when multiple comparable comparators may be used in the same application.

    Returns
    DateComparator — the singleton instance of a DateComparator.