Lua Time Conversion SEC conversion to date __ Time conversion

Source: Internet
Author: User
Tags gettext lua
function common:second2datestring (second, withsecond) local
	HMS = Split (Fxgamemaths:formatsecondstotime (second) , ":") local
	datestr = "" "Local
	
	H = tonumber (hms[1])
	if h > 0 then
		if h >=-then local
			d = Mat H.floor (h/24)
			datestr = d. Fxlanguage:getinstance (): GetString ("@Days")
		end
		datestr = Datestr. (h% 24). Fxlanguage:getinstance (): GetString ("@Hour") end local
	
	m = Tonumber (hms[2))
	if h > 0 or M > 0 then
  datestr = Datestr. M.. Fxlanguage:getinstance (): GetString ("@Minute")
	end
	
	if Withsecond = = Nil or Withsecond = = TRUE or Datestr = "" th En local
		s = Tonumber (hms[3])
		datestr = Datestr. S.. Fxlanguage:getinstance (): GetString ("@Second") End return
	
	datestr
End
Second, time is seconds, Withsecond
Local TIMESTR = Common:second2datestring (Thisactivityinfo.remaintime, false);--Conversion to time function--seconds to date

/** * Conversion times * @param time (seconds) * @param type 0 (time minutes) 1 (06:59:59) * @param nosec whether with seconds */Static ConvertTime (time:number, type:number = 1, Nosec:boolean = False): string {var day:nu
            Mber = Math.floor (time/86400);
            var $day: number = day * 86400;
            var hour:number = Math.floor ((time-$day)/3600);
            var $hour: number = hour * 3600;
            var min:number = Math.floor (time-$day-$hour)/60);
            var $min: number = min * 60;
            var sen:number = Math.Round (time-$day-$hour-$min);//rounded integer var str:string = ""; if (type = = 0) {if (Day > 0) {str = day.tostring () + LangManager.instance.getTex
                T ("@Day");
                } if (Hour > 0) {str + = hour.tostring () + LangManager.instance.getText ("@Hour");
                  } if (min > 0) {  STR + + min.tostring () + LangManager.instance.getText ("@Minute"); } if (Sen > 0 &&!nosec) {str + + sen.tostring () + LangManager.instance.get
                Text ("@Second");
                } else if (type = = 1) {Hour + = day * 24;
                    if (Hour > 0) {if (hour <) {str = "0";
                STR + + hour.tostring () + ":";
                else {str = "00:";
                    } if (min > 0) {if (min <) {str = "0";
                STR + + min.tostring () + ":";
                else {str = "00:"; } if (Sen > 0 &&!nosec) {if (Sen <) {str +
  = "0";                  STR + + sen.tostring ();
                else {str = "00";
        } return str; }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.