[Lada-commits] [PATCH] Use UTC date in messprogramm to generate probe objects

Wald Commits scm-commit at wald.intevation.org
Wed Sep 7 17:16:43 CEST 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1473261386 -7200
# Node ID 62f374ea7ab7ed4f28df82a95c928b729be8c52d
# Parent  d7bcd31ceaa67279713c8148c2d82f2b923e1c95
Use UTC date in messprogramm to generate probe objects.

diff -r d7bcd31ceaa6 -r 62f374ea7ab7 app/model/Messprogramm.js
--- 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;
             }
         }
     }, {
diff -r d7bcd31ceaa6 -r 62f374ea7ab7 app/view/window/GenProbenFromMessprogramm.js
--- 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',


More information about the Lada-commits mailing list