Revision: 4562
          http://sourceforge.net/p/vexi/code/4562
Author:   mkpg2
Date:     2013-10-10 13:22:06 +0000 (Thu, 10 Oct 2013)
Log Message:
-----------
Instant.addMillis(). Support adding time to an instant.

Modified Paths:
--------------
    branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSInstant.jpp

Modified: 
branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSInstant.jpp
===================================================================
--- branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSInstant.jpp   
2013-10-10 03:20:24 UTC (rev 4561)
+++ branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSInstant.jpp   
2013-10-10 13:22:06 UTC (rev 4562)
@@ -100,9 +100,8 @@
 
     final public Instant instant;
     
-    public JSInstant(Instant instant) {
-        this.instant = instant;
-    }
+    public JSInstant(long millis) { this(new Instant(millis)); }
+    public JSInstant(Instant instant) { this.instant = instant; }
 
     public String coerceToString() { return instant.format(getTimeZone()); }
 
@@ -115,10 +114,17 @@
        case "format": return METHOD;
        case "getDate": return METHOD;
         case "getTime": return METHOD;
-        case "diff": return METHOD; 
+        case "diff": return METHOD;
+        case "diffMillis": return METHOD;
+        case "addMillis": return METHOD; 
         //#end
         return super.get(key);
     }
+    
+    private JS diffMillis(JS[] args) throws JSExn{
+        JSInstant from = expectInstant(args,0);
+        return JSU.N(instant.diff(from.instant));
+    }
 
     public JS callMethod(JS this_, JS method, JS[] args) throws JSExn {
         //#switch(JSU.toString(method))
@@ -134,9 +140,11 @@
                TimeZone timezone = expectTimeZone(args,0);
             return JSU.S(instant.getTime(timezone));
         }
-        case "diff": { 
-            JSInstant from = expectInstant(args,0);
-            return JSU.N(instant.diff(from.instant));
+        case "diffMillis": return diffMillis(args);
+        case "diff": return diffMillis(args);
+        case "addMillis": { 
+               int amount = JSU.expectArg_int(args,0);
+            return new JSInstant(instant.millis()+amount);
         }
         //#end
         return super.callMethod(this_, method, args);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to