Mercurial > lada > lada-client
changeset 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 | 695e93e3275d |
children | 1179a6358213 |
files | app/model/Messprogramm.js app/view/widget/DayOfYear.js |
diffstat | 2 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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'
--- 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); } },