mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-31 22:49:23 +08:00
完善pomelo客户端
This commit is contained in:
25
PomeloClient/assets/Script/view/utils/TimeUtil.js
Normal file
25
PomeloClient/assets/Script/view/utils/TimeUtil.js
Normal file
@@ -0,0 +1,25 @@
|
||||
function TimeUtil() {
|
||||
console.log('TimeUtil');
|
||||
}
|
||||
|
||||
//pads n with zeros on the left,
|
||||
//digits is minimum length of output
|
||||
//zeroPad(3, 5); returns "005"
|
||||
//zeroPad(2, 500); returns "500"
|
||||
function zeroPad(digits, n) {
|
||||
n = n.toString();
|
||||
while (n.length < digits)
|
||||
n = '0' + n;
|
||||
return n;
|
||||
};
|
||||
|
||||
//it is almost 8 o'clock PM here
|
||||
//timeString(new Date); returns "19:49"
|
||||
TimeUtil.prototype.timeString = function (date) {
|
||||
console.log('timeString');
|
||||
var minutes = date.getMinutes().toString();
|
||||
var hours = date.getHours().toString();
|
||||
return zeroPad(2, hours) + ":" + zeroPad(2, minutes);
|
||||
};
|
||||
|
||||
module.exports = new TimeUtil();
|
||||
9
PomeloClient/assets/Script/view/utils/TimeUtil.js.meta
Normal file
9
PomeloClient/assets/Script/view/utils/TimeUtil.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "04425e17-a421-408e-8891-81835fce9781",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user