X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FJSDate.java;h=ca9c5b7ce12ccd5b716b02bddae4bc7e924f38e9;hb=7e9239a7088d4cd772a31a76e1a53e1c681638bc;hp=901ee9df667247b1a106dc7d4d6b73fc4f67d1b5;hpb=8c1756ef3fd42cc2f324baf47e13a83f51045efe;p=org.ibex.core.git diff --git a/src/org/xwt/js/JSDate.java b/src/org/xwt/js/JSDate.java index 901ee9d..ca9c5b7 100644 --- a/src/org/xwt/js/JSDate.java +++ b/src/org/xwt/js/JSDate.java @@ -48,7 +48,7 @@ import java.text.SimpleDateFormat; * @author Mike McCabe * @author Adam Megacz (many modifications */ -public class JSDate extends JSCallable { +public class JSDate extends JS { public JSDate() { if (thisTimeZone == null) { @@ -61,7 +61,7 @@ public class JSDate extends JSCallable { public String coerceToString() { return date_format(date, FORMATSPEC_FULL); } - public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) { + public Object callMethod(Object method, Object a0, Object a1, Object a2, Object[] rest, int nargs) throws JSExn { switch(nargs) { case 0: { //#switch(method) @@ -126,7 +126,7 @@ public class JSDate extends JSCallable { return super.callMethod(method, a0, a1, a2, rest, nargs); } - public Object get(Object key) { + public Object get(Object key) throws JSExn { //#switch(key) case "toString": return METHOD; case "toTimeString": return METHOD; @@ -896,70 +896,62 @@ public class JSDate extends JSCallable { private static double _toNumber(Object[] o, int index) { return JS.toDouble(o[index]); } private static double toDouble(double d) { return d; } - public JSDate(JSArray args_) { - Object[] args = new Object[args_.length()]; - for(int i=0; i= 2) array[2] = toDouble(a2); + for(int i=0; i= 0 && array[0] <= 99) + array[0] += 1900; + + /* if we got a 0 for 'date' (which is out of range) + * pretend it's a 1 */ + if (array[2] < 1) + array[2] = 1; + + double day = MakeDay(array[0], array[1], array[2]); + double time = MakeTime(array[3], array[4], array[5], array[6]); + time = MakeDate(day, time); + time = internalUTC(time); + obj.date = TimeClip(time); + + return; } } - - /* adjust 2-digit years into the 20th century */ - if (array[0] >= 0 && array[0] <= 99) - array[0] += 1900; - - /* if we got a 0 for 'date' (which is out of range) - * pretend it's a 1 */ - if (array[2] < 1) - array[2] = 1; - - double day = MakeDay(array[0], array[1], array[2]); - double time = MakeTime(array[3], array[4], array[5], array[6]); - time = MakeDate(day, time); - time = internalUTC(time); - obj.date = TimeClip(time); - - return; } /* constants for toString, toUTCString */