Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synced changes from the walkner-wmes project.
- Loading branch information
Showing
30 changed files
with
326 additions
and
376 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
// Copyright (c) 2014, Łukasz Walukiewicz <lukasz@walukiewicz.eu>. Some Rights Reserved. | ||
// Licensed under CC BY-NC-SA 4.0 <http://creativecommons.org/licenses/by-nc-sa/4.0/>. | ||
// Part of the walkner-tp project <http://lukasz.walukiewicz.eu/p/walkner-tp> | ||
|
||
'use strict'; | ||
|
||
exports.formatDate = function(date) | ||
{ | ||
if (!date) | ||
{ | ||
return ''; | ||
} | ||
|
||
if (!(date instanceof Date)) | ||
{ | ||
date = new Date(date); | ||
} | ||
|
||
var result = date.getFullYear() + '-'; | ||
var month = date.getMonth() + 1; | ||
var day = date.getDate(); | ||
|
||
if (month < 10) | ||
{ | ||
result += '0' + month; | ||
} | ||
else | ||
{ | ||
result += month; | ||
} | ||
|
||
if (day < 10) | ||
{ | ||
result += '-0' + day; | ||
} | ||
else | ||
{ | ||
result += '-' + day; | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
exports.formatTime = function(date) | ||
{ | ||
if (!date) | ||
{ | ||
return ''; | ||
} | ||
|
||
if (!(date instanceof Date)) | ||
{ | ||
date = new Date(date); | ||
} | ||
|
||
var hours = date.getHours(); | ||
var minutes = date.getMinutes(); | ||
var seconds = date.getSeconds(); | ||
var result = hours < 10 ? ('0' + hours) : hours; | ||
|
||
if (minutes < 10) | ||
{ | ||
result += ':0' + minutes; | ||
} | ||
else | ||
{ | ||
result += ':' + minutes; | ||
} | ||
|
||
if (seconds < 10) | ||
{ | ||
result += ':0' + seconds; | ||
} | ||
else | ||
{ | ||
result += ':' + seconds; | ||
} | ||
|
||
return result; | ||
}; | ||
|
||
exports.formatDateTime = function(date) | ||
{ | ||
if (!date) | ||
{ | ||
return ''; | ||
} | ||
|
||
if (!(date instanceof Date)) | ||
{ | ||
date = new Date(date); | ||
} | ||
|
||
var result = date.getFullYear(); | ||
var month = date.getMonth() + 1; | ||
var day = date.getDate(); | ||
var hours = date.getHours(); | ||
var minutes = date.getMinutes(); | ||
var seconds = date.getSeconds(); | ||
|
||
if (month < 10) | ||
{ | ||
result += '-0' + month; | ||
} | ||
else | ||
{ | ||
result += '-' + month; | ||
} | ||
|
||
if (day < 10) | ||
{ | ||
result += '-0' + day; | ||
} | ||
else | ||
{ | ||
result += '-' + day; | ||
} | ||
|
||
if (hours < 10) | ||
{ | ||
result += ' 0' + hours; | ||
} | ||
else | ||
{ | ||
result += ' ' + hours; | ||
} | ||
|
||
if (minutes < 10) | ||
{ | ||
result += ':0' + minutes; | ||
} | ||
else | ||
{ | ||
result += ':' + minutes; | ||
} | ||
|
||
if (seconds < 10) | ||
{ | ||
result += ':0' + seconds; | ||
} | ||
else | ||
{ | ||
result += ':' + seconds; | ||
} | ||
|
||
return result; | ||
}; |
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
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
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
Oops, something went wrong.