Created
June 2, 2015 17:47
-
-
Save 1ambda/159131e7ba919bbb6bce to your computer and use it in GitHub Desktop.
Time.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Syrup | |
this.formatDate = function(num){ | |
var fom = ""; | |
var iNum; | |
if(!isNaN(num)){ | |
iNum = Number(num); | |
if(iNum < 10) { fom = "0" + iNum; } | |
else { fom = "" + iNum; } | |
return fom; | |
} | |
return num; | |
}; | |
this.getLatencyId = function() { | |
var today = new Date(); | |
var to_year = today.getFullYear(); | |
var to_month = this.formatDate(today.getMonth() + 1); | |
var to_date = this.formatDate(today.getDate()); | |
var to_hours = this.formatDate(today.getHours()); | |
var to_minutes = this.formatDate(today.getMinutes()); | |
var to_seconds = this.formatDate(today.getSeconds()); | |
return [to_year, to_month, to_date, to_hours, to_minutes, to_seconds, today.getMilliseconds()].join(""); | |
} | |
// Rake | |
timeStamp: function(date) { | |
var date_str = date.getFullYear().toString(); | |
date_str += (((date.getMonth()+1)<10?'0':''))+(date.getMonth()+1).toString(); | |
date_str += ((date.getDate()<10?'0':'') + date.getDate()).toString(); | |
var hours = (date.getHours()<10?'0':'') + date.getHours() | |
date_str += hours.toString(); | |
date_str += ((date.getMinutes()<10?'0':'') + date.getMinutes()).toString(); | |
date_str += ((date.getSeconds()<10?'0':'') + date.getSeconds()).toString(); | |
var milliseconds = date.getMilliseconds(); | |
if(milliseconds < 10){ | |
date_str += '00'; | |
}else if(milliseconds <100){ | |
date_str += '0'; | |
} | |
date_str += milliseconds.toString(); | |
return date_str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment