Revision: 4690
          http://sourceforge.net/p/vexi/code/4690
Author:   mkpg2
Date:     2014-04-24 06:20:35 +0000 (Thu, 24 Apr 2014)
Log Message:
-----------
Date. New part weekyear.
- returns value based on the default week calendar (i.e. only supported one 
currently)
- can return different year to the year part (i.e. first few days of the year 
often belong to the last week of previous year).
Fix weekfield, date selection.

Modified Paths:
--------------
    branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDate.jpp
    branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/date/week.js
    branches/vexi3/org.vexi-library.value/src/main/java/org/vexi/value/Date.java
    
branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/weekfield.t

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      
2014-04-23 21:26:58 UTC (rev 4689)
+++ branches/vexi3/org.vexi-library.js/src/main/jpp/org/ibex/js/JSDate.jpp      
2014-04-24 06:20:35 UTC (rev 4690)
@@ -173,13 +173,19 @@
         /* The year as a standard Gregorian date.
          * @type(Number) */
         case "day": return getPartJS(key);
-        case "week":  return getPartJS(key);
         case "weekday":  return getPartJS(key);
         case "hour":    return getPartJS(key);
         case "minute":  return getPartJS(key);
         case "time":     return JSU.S(date.formatTime());
         case "seconds":  throw new JSExn("Unsupported: "+key);
-            
+
+        // REMARK default week calendar only. Ultimately we need to support
+        // different week calendars, and then the calendar would have to be
+        // passed/associated in order to get a proper answer for these parts.
+        case "week":  return getPartJS(key);
+        case "weekyear": return getPartJS(key);
+
+        
         case "scheme": return JSU.S(date.getScheme().name);
 
         /* <p>Adds period*number to the given date, returning

Modified: 
branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/date/week.js
===================================================================
--- branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/date/week.js  
2014-04-23 21:26:58 UTC (rev 4689)
+++ branches/vexi3/org.vexi-library.js/src/test/java/test/js/exec/date/week.js  
2014-04-24 06:20:35 UTC (rev 4690)
@@ -1,10 +1,20 @@
 sys.import("shared");
 
 const Date = sys.js.Date;
-const ymd  = new Date("YMD",2013,8,27);
-assertEquals(3, ymd.weekday);
+{
+       const ymd1  = new Date("YMD",2014,1,1);
+       assertEquals(2013, ymd1.weekyear);
+       assertEquals(52, ymd1.week);
+       
+       const ymd2  = new Date("YMD",2014,1,5);
+       assertEquals(2014, ymd2.weekyear);
+       assertEquals(1, ymd2.week);
 
+}
 
+
+
+
 //REMARK eventually will probably have to support a calendar system
 //as different systems exist with different definitions of which the first
 //week of a given year is...

Modified: 
branches/vexi3/org.vexi-library.value/src/main/java/org/vexi/value/Date.java
===================================================================
--- 
branches/vexi3/org.vexi-library.value/src/main/java/org/vexi/value/Date.java    
    2014-04-23 21:26:58 UTC (rev 4689)
+++ 
branches/vexi3/org.vexi-library.value/src/main/java/org/vexi/value/Date.java    
    2014-04-24 06:20:35 UTC (rev 4690)
@@ -61,8 +61,9 @@
                            
            PART_QUARTER = -5,
                PART_WEEKDAY = -6,
-               PART_WEEK = -7;
-    
+               PART_WEEK = -7,
+       PART_WEEKYEAR = -8;
+               
     static public int partId(String partName) throws ValueException{
         if("year".equals(partName)) return PART_YEAR;
         if("month".equals(partName)) return PART_MONTH;
@@ -73,6 +74,7 @@
         if("quarter".equals(partName)) return PART_QUARTER;
         if("weekday".equals(partName)) return PART_WEEKDAY;
         if("week".equals(partName)) return PART_WEEK;
+        if("weekyear".equals(partName)) return PART_WEEKYEAR;
         throw new ValueException("No such part: "+partName);
     }
     static public String partName(int partId){
@@ -85,6 +87,7 @@
         case PART_QUARTER: return "quarter";
         case PART_WEEKDAY: return "weekday";
         case PART_WEEK: return "week";
+        case PART_WEEKYEAR: return "weekyear";
         }
         throw new Error("No such part: "+partId);
     }
@@ -98,7 +101,16 @@
         case PART_QUARTER: return (cal.get(Calendar.MONTH)/3)+1;
         case PART_WEEKDAY: return cal.get(Calendar.DAY_OF_WEEK);
         case PART_WEEK: return cal.get(Calendar.WEEK_OF_YEAR);
+        case PART_WEEKYEAR: {
+               int r = cal.get(Calendar.YEAR);
+               int wk = cal.get(Calendar.WEEK_OF_YEAR);
+               int month = cal.get(Calendar.MONTH);
+            if(wk>20 && month==Calendar.JANUARY){
+               r = r-1;
+            }
+               return r;
         }
+        }
         throw new Error("No such part: "+partId);
     }
     
@@ -188,10 +200,11 @@
                }       
                
            Calendar initCalendar(Calendar c){
-               if(hasPart(PART_WEEK)){
+               // REMARK currently only support a single week scheme
+//             if(hasPart(PART_WEEK)){
                        c.setMinimalDaysInFirstWeek(7);
                        c.setFirstDayOfWeek(Calendar.SUNDAY);
-               }
+//             }
                return c;
            }
            
@@ -371,6 +384,7 @@
        if(partId==PART_QUARTER) return hasPart(PART_MONTH);
        if(partId==PART_WEEKDAY) return hasPart(PART_DAY);
        if(partId==PART_WEEK) return hasPart(PART_WEEK) || hasPart(PART_DAY);   
        
+       if(partId==PART_WEEKYEAR) return hasPart(PART_WEEK) || 
hasPart(PART_DAY);       
        return false;
     }
     
@@ -461,12 +475,12 @@
                return c;
        }else{
        
-                   return new GregorianCalendar(
+                   return scheme.initCalendar(new GregorianCalendar(
                        getPartDefault(PART_YEAR),
                        getPartDefault(PART_MONTH)-1,
                        getPartDefault(PART_DAY),
                        getPartDefault(PART_HOUR),
-                       getPartDefault(PART_MINUTE)
+                       getPartDefault(PART_MINUTE))
                );
        }
     }

Modified: 
branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/weekfield.t
===================================================================
--- 
branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/weekfield.t
    2014-04-23 21:26:58 UTC (rev 4689)
+++ 
branches/vexi3/org.vexi-vexi.widgets/src_main/org/vexi/theme/classic/weekfield.t
    2014-04-24 06:20:35 UTC (rev 4690)
@@ -247,9 +247,7 @@
         datepicker_box.action ++= function(v) {
             datefield.day = null;
             var date = new vexi.js.Date("YMD", datepicker_box.year, 
datepicker_box.month, datepicker_box.day);
-            trace(date);
-            trace(date.week);
-            datefield.value = new vexi.js.Date("YW", date.year, date.week);
+            datefield.value = new vexi.js.Date("YW", date.weekyear, date.week);
             cascade = v;
         }
         

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


------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to