Revision: 4848
          http://sourceforge.net/p/vexi/code/4848
Author:   mkpg2
Date:     2016-03-16 21:35:57 +0000 (Wed, 16 Mar 2016)
Log Message:
-----------
Date.nameOfMonth(), Date.nameOfWeek(). Built in methods for this, otherwise 
duplicating everywhere in vexi code.

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

Modified: branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDate.jpp
===================================================================
--- branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDate.jpp      
2016-03-16 15:34:17 UTC (rev 4847)
+++ branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDate.jpp      
2016-03-16 21:35:57 UTC (rev 4848)
@@ -34,6 +34,11 @@
  
 public class JSDate extends JS.Immutable {
 
+       static String[] WEEKDAYS = {"Sunday", "Monday", "Tuesday", "Wednesday", 
"Thursday", "Friday", "Saturday"};
+       static String[] MONTHS   = 
{"January","February","March","April","May","June","July","August","September","October","November","December"};
+       
+   
+       
     static private JSDate expectDate(JS[] args, int i) throws JSExn {
         JSDate arg = expectDateOrNull(args, i);
         if (arg==null ) 
@@ -73,6 +78,8 @@
                 return new JSDate(new 
Instant().getDate(JSInstant.getTimeZone()));
             case "compare": 
                 return METHOD;
+            case "nameOfMonth":   return METHOD;
+            case "nameOfWeekday": return METHOD;
 
             case "tryParseString": 
                 return METHOD;
@@ -113,6 +120,17 @@
                        JSDate b = expectDateOrNull(args,1); 
                        if(a==null || b==null) return null;
                        return JSU.N(a.date.compareTo(b.date));
+                   case "nameOfMonth":{
+                       int m = JSU.expectArg_int(args,0);
+                       if(m<=0 || m>12) throw new JSExn("Expected 1-12, got 
"+m);
+                       return JSU.S(MONTHS[m-1],true);
+                   }   
+                       
+                   case "nameOfWeekday":{
+                       int weekday = JSU.expectArg_int(args,0);
+                       if(weekday<=0 || weekday>7) throw new JSExn("Expected 
1-7, got "+weekday);
+                       return JSU.S(WEEKDAYS[weekday-1],true);
+                   }   
                    //#end
                    return super.callMethod(this_, method, args);
                }catch(ValueException e){

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


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to