home *** CD-ROM | disk | FTP | other *** search
- import java.util.Date;
-
- public class JScriptDateObject extends JSbxObject implements JSbxPropertyInterface {
- public static final String NAME = "Date";
- private static final int DATE_ID_GETDATE = 1;
- private static final int DATE_ID_GETDAY = 2;
- private static final int DATE_ID_GETHOURS = 3;
- private static final int DATE_ID_GETMINUTES = 4;
- private static final int DATE_ID_GETMONTH = 5;
- private static final int DATE_ID_GETSECONDS = 6;
- private static final int DATE_ID_GETTIME = 7;
- private static final int DATE_ID_GETTIMEZONEOFFSET = 8;
- private static final int DATE_ID_GETYEAR = 9;
- private static final int DATE_ID_SETDATE = 11;
- private static final int DATE_ID_SETHOURS = 12;
- private static final int DATE_ID_SETMINUTES = 13;
- private static final int DATE_ID_SETMONTH = 14;
- private static final int DATE_ID_SETSECONDS = 15;
- private static final int DATE_ID_SETTIME = 16;
- private static final int DATE_ID_SETYEAR = 17;
- private static final int DATE_ID_TOGMTSTRING = 18;
- private static final int DATE_ID_TOLOCALESTRING = 19;
- private Date aDate = new Date();
-
- public void SetDate(Date var1) {
- this.aDate = var1;
- }
-
- public String GetString() {
- return this.aDate.toString();
- }
-
- public JScriptDateObject(JScriptConstructor var1) {
- super(var1);
-
- try {
- ((JSbxObject)this).Put(new JSbxObjectProperty("getDate", this, this, 1, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getDay", this, this, 2, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getHours", this, this, 3, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getMinutes", this, this, 4, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getMonth", this, this, 5, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getSeconds", this, this, 6, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getTime", this, this, 7, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getTimezoneOffset", this, this, 8, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("getYear", this, this, 9, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setDate", this, this, 11, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setHours", this, this, 12, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setMinutes", this, this, 13, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setMonth", this, this, 14, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setSeconds", this, this, 15, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setTime", this, this, 16, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("setYear", this, this, 17, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("toGMTString", this, this, 18, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("toLocaleString", this, this, 19, false, true));
- } catch (JSbxException var2) {
- }
- }
-
- public JSbxValue PropertyCallFunction(JSbxObjectProperty var1, JScriptCallParam var2) throws JSbxExceptionBase {
- JSbxVector var3 = var2.GetParamVector();
- int var4 = var1.GetID();
- String var5 = "";
- double var6 = (double)0.0F;
- boolean var8 = true;
- boolean var9 = false;
- switch (var4) {
- case 1:
- var6 = (double)this.aDate.getDate();
- break;
- case 2:
- var6 = (double)this.aDate.getDay();
- break;
- case 3:
- var6 = (double)this.aDate.getHours();
- break;
- case 4:
- var6 = (double)this.aDate.getMinutes();
- break;
- case 5:
- var6 = (double)this.aDate.getMonth();
- break;
- case 6:
- var6 = (double)this.aDate.getSeconds();
- break;
- case 7:
- var6 = (double)this.aDate.getTime();
- break;
- case 8:
- var6 = (double)this.aDate.getTimezoneOffset();
- if (var6 != (double)0.0F) {
- var6 = Math.abs(var6) / var6 * (Math.abs(var6) + (double)1.0F);
- }
- break;
- case 9:
- var6 = (double)this.aDate.getYear();
- if (var6 < (double)0.0F || var6 >= (double)100.0F) {
- var6 += (double)1900.0F;
- }
- case 10:
- default:
- break;
- case 11:
- this.aDate.setDate((int)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 12:
- this.aDate.setHours((int)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 13:
- this.aDate.setMinutes((int)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 14:
- this.aDate.setMonth((int)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 15:
- this.aDate.setSeconds((int)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 16:
- this.aDate.setTime((long)JScriptWindowObject.GetDoubleParam(var3, 0));
- var9 = true;
- break;
- case 17:
- int var10 = (int)JScriptWindowObject.GetDoubleParam(var3, 0);
- if (var10 > 0) {
- var10 -= 1900;
- }
-
- this.aDate.setYear(var10);
- var9 = true;
- break;
- case 18:
- var5 = this.aDate.toGMTString();
- var8 = false;
- break;
- case 19:
- var5 = this.aDate.toLocaleString();
- var8 = false;
- }
-
- Object var11 = null;
- JSbxValue var12;
- if (var9) {
- var12 = new JSbxValue();
- } else if (var8) {
- var12 = new JSbxValue(var6);
- } else {
- var12 = new JSbxValue(var5);
- }
-
- var2.GetRuntimeParam().SetReturnValue(var12);
- return var12;
- }
-
- public void PropertyGet(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
- }
-
- public void PropertyPut(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
- }
-
- public String Property_GetJScript_typeofString(JSbxObjectProperty var1) {
- return "dateobject";
- }
-
- public String GetJScriptString(boolean var1) {
- return this.aDate.toString();
- }
-
- public JSbxValue GetJScriptValue() {
- return new JSbxValue((double)this.aDate.getTime());
- }
- }
-