diff lib/js/urweb.js @ 1980:334b5cbff198

Bare-bones Datetime JS support.
author Patrick Hurst <phurst@mit.edu>
date Mon, 20 Jan 2014 04:34:42 -0500
parents a671e5258a2c
children
line wrap: on
line diff
--- a/lib/js/urweb.js	Sat Jan 18 18:26:24 2014 -0500
+++ b/lib/js/urweb.js	Mon Jan 20 04:34:42 2014 -0500
@@ -217,13 +217,13 @@
 	    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 @@
 	    {
 		idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
 	    }
-	    
+
 	    return xPad(idow, 0);
 	},
 	w: "getDay",
@@ -345,7 +345,36 @@
     var thisDate = new Date();
     thisDate.setTime(Math.floor(thisTime / 1000));
     return Dt.format(thisDate, fmt);
-}; 
+};
+
+
+function datetimeYear(tm) {
+    return new Date(tm).getYear();
+}
+
+function datetimeMonth(tm) {
+    return new Date(tm).getMonth();
+}
+
+function datetimeDay(tm) {
+    return new Date(tm).getDate();
+}
+
+function datetimeHour(tm) {
+    return new Date(tm).getHours();
+}
+
+function datetimeMinute(tm) {
+    return new Date(tm).getMinutes();
+}
+
+function datetimeSecond(tm) {
+    return new Date(tm).getSeconds();
+}
+
+function datetimeDayOfWeek(tm) {
+    return new Date(tm).getDay();
+}
 
 
 // Error handling
@@ -717,7 +746,7 @@
     if (node.tagName == "SCRIPT") {
         var savedScript = thisScript;
         thisScript = node;
-        
+
         try {
             eval(thisScript.text);
         } catch (v) {
@@ -1102,7 +1131,7 @@
         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 +1152,7 @@
         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);