Hi,

I have try to make somthing like this may help you.

// function to compare  dates //

        public static function getDiff(dateTarget:Date,
dateActual:Date):Object {

                var MILLISECONDS_PER_DAY:int = 1000 * 60 * 60 * 24;
                var MILLISECONDS_PER_HOUR:int = 1000 * 60 * 60;
                var MILLISECONDS_PER_MIN:int = 1000 * 60;
                var MILLISECONDS_PER_SEC:int = 1000;

                        var diff:Number = dateTarget.getTime()- 
dateActual.getTime();
                        var swapBool : Boolean = false;
                        if(diff < 0)
                        {
                                // in case of dateActual is bigger than 
dateTarget so swap it
                                swapBool = true;
                                var td : Date = dateActual;
                                dateActual = dateTarget;
                                dateTarget = td;
                                diff = dateTarget.getTime()- 
dateActual.getTime();
                        }
                        var num:Number = diff/MILLISECONDS_PER_DAY;
                        var d : int = Math.floor(num);
                        var str : String = "Day:" + d.toString();
                        diff = diff - ( d* MILLISECONDS_PER_DAY );
                        num = diff/MILLISECONDS_PER_HOUR;
                        var h : int = Math.floor(num);
                        str += " Hour:" + h.toString();
                        diff = diff - ( h* MILLISECONDS_PER_HOUR );
                        num = diff/MILLISECONDS_PER_MIN;
                        var m : int = Math.floor(num);
                        str += " Min:" + m.toString();
                        diff = diff - ( m* MILLISECONDS_PER_MIN );
                        num = diff/MILLISECONDS_PER_SEC;
                        var s : int = Math.floor(num);
                        str += " Sec:" + s.toString();
                        var retObj : Object = new Object();
                        retObj.diffStr = str;
                        retObj.swapBool = swapBool;
                        return retObj;
           }

// Call function example //

var dateTarget : Date = new Date(2010,4,8,11,42,30);
var dateActual : Date = new Date();

var diffObj : Object = ManageDate.getDiff(dateTarget, dateActual);
if( Boolean( diffObj.swapBool ) )
        trace ( "dateActual is greater than dateTarget by = " +
diffObj.diffStr );
else
        trace ( "dateTarget is greater than dateActual by = " +
diffObj.diffStr );

--------------
Regards,
v...@t

On May 7, 11:07 pm, Kentor <[email protected]> wrote:
> Hi,
>
> Does anybody know of a class which will compare dates (the current
> date and a given date) and return a string like "10 secs ago, 2 mins
> ago, 1 hour ago, 1 day ago, 2 months ago, etc".. like on facebook or
> twitter ?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group 
> athttp://groups.google.com/group/flex_india?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to