C++/Qt封装函数(毫秒转成时间戳,数字每隔三位加点字符操作)

毫秒转成时间戳

void timestamp(int leftTime)
{
	int ss = 1000;
	int mm = ss * 60;
	int hh = mi * 60;
	int dd = hh * 24;
	long day = leftTime / dd;
	long hour = (leftTime - day * dd) / hh;
	long min = (leftTime - day * dd - hour * hh) / mm;
	long second = (leftTime - day * dd - hour * hh - min * mm) / ss;
}

数字每隔三位加点字符操作

void addCommas(QString strNum)
{
	int len = strNum.length();
	for (int index = len - 3; index > 0; index -= 3) {
		strNum.insert(index, ",");
	}
}

你可能感兴趣的:(C/C++,Qt)