Search code examples
actionscriptflash-cs6

display current date and time in Arabic format using as3


hi can I display current date and time in Arabic format using flash CS6 and as3

var now:Date=new Date()
    this["st_rep"+c]["date"].text=now.toDateString()
            this["st_rep"+c]["time"].text=now.toTimeString().slice(0,8)

thank's in advance


Solution

  • nice solution for the arabic numbers :). You can write a simpler version of the function like this:

    function convert_arabic(str:String)
    {
        var eng_num = ["0","1","2","3","4","5","6","7","8","9"];
        var ara_num = ["۰","۱","۲","۳","٤","٥","٦","۷","۸","۹"];
    
        for(var f:int = 0; f < eng_num.length; f++)
            str = str.replace(new RegExp(eng_num[f], "g"), ara_num[f]);
    
        return str;
    }
    

    regards,