changeset 1191:62f374ea7ab7

Use UTC date in messprogramm to generate probe objects.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 07 Sep 2016 17:16:26 +0200
parents d7bcd31ceaa6
children 3e078af76b58
files app/model/Messprogramm.js app/view/window/GenProbenFromMessprogramm.js
diffstat 2 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/model/Messprogramm.js	Wed Aug 31 15:56:07 2016 +0200
+++ b/app/model/Messprogramm.js	Wed Sep 07 17:16:26 2016 +0200
@@ -84,7 +84,12 @@
         },
         serialize: function(value) {
             if (value instanceof Date && !isNaN(value.valueOf())) {
-                return Ext.Date.getDayOfYear(value);
+                var dayOfYear = Ext.Date.getDayOfYear(value);
+                var offset = value.getTimezoneOffset();
+                if (offset == 0) {
+                    return dayOfYear;
+                }
+                return offset > 0 ? dayOfYear - 1 : dayOfYear + 1;
             }
         }
     }, {
@@ -112,7 +117,12 @@
         },
         serialize: function(value) {
             if (value instanceof Date && !isNaN(value.valueOf())) {
-                return Ext.Date.getDayOfYear(value);
+                var dayOfYear = Ext.Date.getDayOfYear(value);
+                var offset = value.getTimezoneOffset();
+                if (offset == 0) {
+                    return dayOfYear;
+                }
+                return offset > 0 ? dayOfYear - 1 : dayOfYear + 1;
             }
         }
     }, {
--- a/app/view/window/GenProbenFromMessprogramm.js	Wed Aug 31 15:56:07 2016 +0200
+++ b/app/view/window/GenProbenFromMessprogramm.js	Wed Sep 07 17:16:26 2016 +0200
@@ -48,13 +48,18 @@
         }, {
             text: i18n.getMsg('generateproben'),
             handler: function() {
+                var startDate = new Date(me.down('datefield[name=start]').getValue());
+                var startUTC = Date.UTC(
+                    startDate.getFullYear(), startDate.getMonth(), startDate.getDate());
+                var endDate = new Date(me.down('datefield[name=end]').getValue());
+                var endUTC = Date.UTC(
+                    endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
                 var jsondata = {
                     id: me.record.id,
-                    start: new Date(me.down('datefield[name=start]').getValue()).valueOf(),
-                    end: new Date(me.down('datefield[name=end]').getValue()).valueOf()
+                    start: startUTC,
+                    end: endUTC
                 };
 
-
                 Ext.Ajax.request({
                     url: 'lada-server/rest/probe/messprogramm',
                     method: 'POST',

http://lada.wald.intevation.org