comparison app/model/Messprogramm.js @ 793:d4eb8fb99b5e

Serialising GueltigVon and GueltigBis natively with Ext
author Dustin Demuth <dustin@intevation.de>
date Wed, 13 May 2015 16:01:24 +0200
parents 4c1101f0ba99
children f4eb53ba63fc
comparison
equal deleted inserted replaced
792:d572ee3271ac 793:d4eb8fb99b5e
60 name: 'intervallOffset' 60 name: 'intervallOffset'
61 }, { 61 }, {
62 name: 'gueltigVon', 62 name: 'gueltigVon',
63 type: 'date', 63 type: 'date',
64 convert: function(v) { 64 convert: function(v) {
65 var firstofyeartimestamp = new Date(
66 Date.UTC(
67 new Date().getFullYear(),0,1))
68 .valueOf();
69 var dayToMilli = 86400000;
70
65 if (!v) { 71 if (!v) {
66 return v; 72 return v;
67 } 73 }
68 return new Date(v); 74 //check if v might be a date
75 // unless we go back in time this will work
76 if (v < 1000) {
77 v = v * dayToMilli;
78 v = v + firstofyeartimestamp;
79 v = new Date(v);
80 }
81 return v;
69 }, 82 },
70 serialize: function(value) { 83 serialize: function(value) {
71 if (value instanceof Date && !isNaN(value.valueOf())) { 84 if (value instanceof Date && !isNaN(value.valueOf())) {
72 return value.getDOY(); 85 return Ext.Date.getDayOfYear(value);
73 } 86 }
74 } 87 }
75 }, { 88 }, {
76 name: 'gueltigBis', 89 name: 'gueltigBis',
77 type: 'date', 90 type: 'date',
78 convert: function(v) { 91 convert: function(v) {
92 var firstofyeartimestamp = new Date(
93 Date.UTC(
94 new Date().getFullYear(),0,1))
95 .valueOf();
96 var dayToMilli = 86400000;
97
79 if (!v) { 98 if (!v) {
80 return v; 99 return v;
81 } 100 }
82 return new Date(v); 101
102 //check if v might be a date
103 // unless we go back in time this will work
104 if (v < 1000) {
105 v = v * dayToMilli;
106 v = v + firstofyeartimestamp;
107 v = new Date(v);
108 }
109 return v;
83 }, 110 },
84 serialize: function(value) { 111 serialize: function(value) {
85 if (value instanceof Date && !isNaN(value.valueOf())) { 112 if (value instanceof Date && !isNaN(value.valueOf())) {
86 return value.getDOY(); 113 return Ext.Date.getDayOfYear(value);
87 } 114 }
88 } 115 }
89 }, { 116 }, {
90 name: 'probeNehmerId' 117 name: 'probeNehmerId'
91 }, { 118 }, {

http://lada.wald.intevation.org