Created
February 25, 2012 22:21
-
-
Save dtryon/1911166 to your computer and use it in GitHub Desktop.
first crack at a module in node.js
This file contains hidden or 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
| var DateFormatter = { | |
| format: function(d) { | |
| var d_date = d.getDate(); | |
| var d_month = d.getMonth(); | |
| d_month++; | |
| var d_year = d.getFullYear(); | |
| var a_p = ''; | |
| var d_hour = d.getHours(); | |
| if (d_hour < 12) | |
| { | |
| a_p = 'AM'; | |
| } | |
| else | |
| { | |
| a_p = 'PM'; | |
| } | |
| if (d_hour == 0) | |
| { | |
| d_hour = 12; | |
| } | |
| if (d_hour > 12) | |
| { | |
| d_hour = d_hour - 12; | |
| } | |
| var d_min = d.getMinutes(); | |
| d_min = d_min + ''; | |
| if (d_min.length == 1) | |
| { | |
| d_min = '0' + d_min; | |
| } | |
| return d_date + '/' + d_month + '/' + d_year + ' ' + d_hour + ' : ' + d_min + ' ' + a_p; | |
| } | |
| } | |
| exports.DateFormatter = new DateFormatter(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment