Permalink
Browse files

Correctly show timezones with minutes, v. 0.1.3 - 2012-12-03

And use [+-]hhmm format instead of [+-]h
  • Loading branch information...
1 parent d5fbcbe commit db55130b111e775cb01df607a3767a3f24bd2b80 @Infocatcher committed Dec 3, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 unixTime.js
View
@@ -1,8 +1,8 @@
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=12600#12600
// http://infocatcher.ucoz.net/js/akelpad_scripts/unixTime.js
-// (c) Infocatcher 2011
-// version 0.1.2 - 2011-05-14
+// (c) Infocatcher 2011-2012
+// version 0.1.3 - 2012-12-03
var TU_AUTO = 0;
var TU_S = 1;
@@ -50,7 +50,7 @@ var dates = [
date.toLocaleString(),
date[tf("getFullYear")]() + "-" + padLeft(date[tf("getMonth")]() + 1) + "-" + padLeft(date[tf("getDate")]()) + " "
+ padLeft(date[tf("getHours")]()) + ":" + padLeft(date[tf("getMinutes")]()) + ":" + padLeft(date[tf("getSeconds")]())
- + " UTC" + (treatAsUTC ? "" : (tzo <= 0 ? "+" : "") + -tzo/60),
+ + " UTC" + (treatAsUTC ? "" : getTimezone(tzo)),
date.toUTCString(),
date.toString(),
ms,
@@ -68,6 +68,12 @@ function padLeft(n) {
? new Array(cnt - n.length + 1).join(chr) + n
: n;
}
+function getTimezone(tzo) {
+ var m = Math.abs(tzo);
+ var h = Math.floor(m/60);
+ m = Math.floor(m - h*60);
+ return (tzo > 0 ? "-" : "+") + padLeft(h) + padLeft(m);
+}
function getArg(argName, defaultVal) {
var args = {};
for(var i = 0, argsCount = WScript.Arguments.length; i < argsCount; i++)

0 comments on commit db55130

Please sign in to comment.