summaryrefslogtreecommitdiff
path: root/lib/js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-02-18 07:07:01 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2014-02-18 07:07:01 -0500
commitf9989b616d8cf4fd1bfd968839bfdbe869468f7a (patch)
treea7d9f1a32d92963d45c8ab93f0fec2396d973bd5 /lib/js
parentc410ff27bef1eb39bc3a28f2f1d151ad2cb75b98 (diff)
parent63fb5cd97f53d36a6ffeec207688127e488447d7 (diff)
Merge with small clean-ups
Diffstat (limited to 'lib/js')
-rw-r--r--lib/js/urweb.js46
1 files changed, 39 insertions, 7 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 6830945a..2e350378 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -217,13 +217,13 @@ var Dt = {
var y = d.getFullYear();
var V = parseInt(Dt.formats.V(d), 10);
var W = parseInt(Dt.formats.W(d), 10);
-
+
if(W > V) {
y++;
} else if(W===0 && V>=52) {
y--;
}
-
+
return y;
},
H: ["getHours", "0"],
@@ -262,7 +262,7 @@ var Dt = {
{
idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
}
-
+
return xPad(idow, 0);
},
w: "getDay",
@@ -345,7 +345,39 @@ function strftime(fmt, thisTime)
var thisDate = new Date();
thisDate.setTime(Math.floor(thisTime / 1000));
return Dt.format(thisDate, fmt);
-};
+};
+
+function fromDatetime(year, month, date, hour, minute, second) {
+ return (new Date(year, month, date, hour, minute, second)).getTime() * 1000;
+};
+
+function datetimeYear(t) {
+ return (new Date(t / 1000)).getYear() + 1900;
+};
+
+function datetimeMonth(t) {
+ return (new Date(t / 1000)).getMonth();
+};
+
+function datetimeDay(t) {
+ return (new Date(t / 1000)).getDate();
+};
+
+function datetimeHour(t) {
+ return (new Date(t / 1000)).getHours();
+};
+
+function datetimeMinute(t) {
+ return (new Date(t / 1000)).getMinutes();
+};
+
+function datetimeSecond(t) {
+ return (new Date(t / 1000)).getSeconds();
+};
+
+function datetimeDayOfWeek(t) {
+ return (new Date(t / 1000)).getDay();
+};
// Error handling
@@ -717,7 +749,7 @@ function runScripts(node) {
if (node.tagName == "SCRIPT") {
var savedScript = thisScript;
thisScript = node;
-
+
try {
eval(thisScript.text);
} catch (v) {
@@ -1102,7 +1134,7 @@ function dynClass(html, s_class, s_style) {
x.signal = s_class;
x.sources = null;
x.closures = htmlCls;
-
+
x.recreate = function(v) {
for (var ls = x.closures; ls != htmlCls; ls = ls.next)
freeClosure(ls.data);
@@ -1123,7 +1155,7 @@ function dynClass(html, s_class, s_style) {
x.signal = s_style;
x.sources = null;
x.closures = htmlCls2;
-
+
x.recreate = function(v) {
for (var ls = x.closures; ls != htmlCls2; ls = ls.next)
freeClosure(ls.data);