[Lada-commits] [PATCH] Align data model with 1-based day of year in server

Wald Commits scm-commit at wald.intevation.org
Fri Sep 30 18:43:33 CEST 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1475253810 -7200
# Node ID 05c8bd380fd5dad8ed6a31753450a42242d624c9
# Parent  695e93e3275df63ed701685aad0cba70cfef50cb
Align data model with 1-based day of year in server.

diff -r 695e93e3275d -r 05c8bd380fd5 app/model/Messprogramm.js
--- a/app/model/Messprogramm.js	Fri Sep 30 15:08:12 2016 +0200
+++ b/app/model/Messprogramm.js	Fri Sep 30 18:43:30 2016 +0200
@@ -61,6 +61,8 @@
     }, {
         name: 'intervallOffset'
     }, {
+        /* day of year is 0-base in ExtJS, but 1-based in Java.
+         * Thus, we expect 1-based values here. */
         name: 'gueltigVon'
     }, {
         name: 'gueltigBis'
diff -r 695e93e3275d -r 05c8bd380fd5 app/view/widget/DayOfYear.js
--- 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);
         }
     },


More information about the Lada-commits mailing list