Show
Ignore:
Timestamp:
08/17/10 13:00:24 (21 months ago)
Author:
mszopinski
Message:

calendar, simple month display

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ssme/trunk/flex/Common/src/com/kh/ssme/util/DateUtil.as

    r4040 r4044  
    3232 
    3333        private var date_:Date; 
     34        public static const MILLISECOND_PER_SECOND:int = 1000; 
     35        public static const MILLISECOND_PER_MINUTE:int = 1000 * 60; 
     36        public static const MILLISECOND_PER_HOUR:int   = 1000 * 60 * 60; 
     37        public static const MILLISECOND_PER_DAY:int    = 1000 * 60 * 60 * 24;         
     38 
    3439 
    3540        public function DateUtil(date:Date) { 
     
    6166            date_[field.property] -= value; 
    6267            return this; 
     68        } 
     69 
     70        /** 
     71         * Returns the difference between this object and given one in provided units 
     72         * Difference is calculated as FLOOR(this - dateUtil) 
     73         * @param dateUtil - DateUtil instance to be compared 
     74         * @param units - Type of unit to be used while calculation, one of MILLISECONDS, SECONDS, MINUTES, HOURS, DAY/DATE 
     75         * @return 
     76         */ 
     77        public function diff(dateUtil:DateUtil, units:DateProperty):Number{ 
     78            var difference:Number = this.date_.time - dateUtil.timestamp; 
     79            if(DateProperty.MILLISECONDS.equals(units)){ 
     80                return difference; 
     81            } else if(DateProperty.SECONDS.equals(units)){ 
     82                return Math.floor( difference/MILLISECOND_PER_SECOND ); 
     83            } else if(DateProperty.MINUTES.equals(units)){ 
     84                return Math.floor( difference/MILLISECOND_PER_MINUTE ); 
     85            } else if(DateProperty.HOURS.equals(units)){ 
     86                return Math.floor( difference/MILLISECOND_PER_HOUR ); 
     87            } else if(DateProperty.DAY.equals(units) || DateProperty.DATE.equals(units)){ 
     88                return Math.floor( difference/MILLISECOND_PER_DAY ); 
     89            } 
     90            return 0; 
    6391        } 
    6492