纳金网

标题: 格式化时间显示 [打印本页]

作者: 她。    时间: 2012-8-7 10:46
标题: 格式化时间显示
非常简短的一段小代码

/// Formats the input string (in seconds) as a human readable

/// string in the form of MM:SS.

/// A of the current playing time.

private string formatedTimeString (string input) {

int seconds;

int minutes;
minutes = Mathf.FloorToInt(input / 60);

seconds = Mathf.FloorToInt(input - minutes * 60);

string r = (minutes < 10) ? "0" + minutes.ToString() : minutes.ToString();

r += ":";

r += (seconds < 10) ? "0" + seconds.ToString() : seconds.ToString();

return r;

}
作者: 她。    时间: 2012-8-7 10:48
哎呀~各位别光看不回帖啊~




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5