diff app/view/widget/DayOfYear.js @ 1207:05c8bd380fd5

Align data model with 1-based day of year in server.
author Tom Gottfried <tom@intevation.de>
date Fri, 30 Sep 2016 18:43:30 +0200
parents 0a7f0a09151c
children 85b018980347
line wrap: on
line diff
--- a/app/view/widget/DayOfYear.js	Fri Sep 30 15:08:12 2016 +0200
+++ b/app/view/widget/DayOfYear.js	Fri Sep 30 18:43:30 2016 +0200
@@ -146,6 +146,8 @@
         var doy = panel.down('numberfield[hidden]').getValue();
 
         if (doy != null) {
+            // day of year is 0-based in ExtJS, but 1-based in the model
+            doy -= 1;
             var date = Ext.Date.subtract(
                 new Date(1970, 0, 1), Ext.Date.DAY, -doy);
             var month = date.getMonth();
@@ -168,7 +170,9 @@
         if (month != null && day != null && day <= maxDay) {
             // create a date object with arbitrary non-leap year
             var date = new Date(1970, month, day);
-            var doy = Ext.Date.getDayOfYear(date);
+
+            // day of year is 0-based in ExtJS, but 1-based in the model
+            var doy = Ext.Date.getDayOfYear(date) + 1;
             panel.down('numberfield[hidden]').setValue(doy);
         }
     },

http://lada.wald.intevation.org