Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date selected is saved as selected date minus 1 day #2

Open
gregorwolf opened this issue Aug 9, 2016 · 9 comments
Open

Date selected is saved as selected date minus 1 day #2

gregorwolf opened this issue Aug 9, 2016 · 9 comments
Assignees
Labels

Comments

@gregorwolf
Copy link
Contributor

When I maintain Saturday, June 10th 2017 as the event date:

edit-event

and save then the date is set to Jun 9th 2017:

Saved-date

When I have a look into the stored date using the HANA OData Explorer I can see that the date was stored like this:

OData Explorer

@thulium3
Copy link
Contributor

thulium3 commented Aug 9, 2016

We need to use a proper timezone handling then. The database stores everything in UTC? Then we need to show all datetime values in local timezone and save it in UTC

@thulium3
Copy link
Contributor

thulium3 commented Aug 9, 2016

I would propose the following solution:

  1. SQL Types in SAP HANA Database should be changed to the following:
    EventDate : Type LocalDate SQL Type Date resolves to Edm.DateTime in OData service
    StartTime, EndTime: Type LocalTime SQL Type Time resolves to Edm.Time in Odata service
  2. In all Frontend Code Dates have to be treated as UTC DateTime. Times do not have a timezone and are automatically correct. @gregorwolf can you change the DBSchema?

@gregorwolf
Copy link
Contributor Author

Hi @thulium3, I would suggest the following: Let's test the adjustments first in my HANA XS PoC Backend and let's create a frontend for that. If we validated in the PoC let's do the change of the DB Schema. OK?

@thulium3
Copy link
Contributor

thulium3 commented Aug 9, 2016

OK. I tried to do the changes in my local sitreg instance but now I cannot activate anything and I am lost. I do not have any XS knowledge so far :-(

@thulium3
Copy link
Contributor

My XS project is not usable anymore. I changed the types in the backend to LocalDate and LocalTime and after much troubles I could activate everything again. But now I get following errors inside of the Editor.

09:35:55] (syntaxcheck) Technical error. Contact your system administrator. Error occurred during syntax check. Proxy: Name: xsodataparser | Message: Original error message: Proxy: Name: xsodataparser | Message: Error loading module from path 'sap.hana.ide.common.parsers/service/XSODataParserImpl'
Original error message:
Error stack: Error
at ByteCode.read (https://sitregsxxxtrial.hanatrial.ondemand.com/sap/hana/ide/editor/plugin/editors/hdbdd/rndrt/rnd.js:440:13)
at new OSDLParser (https://sitregxxxtrial.hanatrial.ondemand.com/sap/hana/ide/common/plugin/parsers/xsodata/OSDLParser.js:17:27)
at https://sitregxxxtrial.hanatrial.ondemand.com/sap/hana/ide/common/plugin/parsers/service/XSODataParserImpl.js:7:15
at Object.execCb (https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:1550:21)
at Object.check (https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:806:28)
at Object. (https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:1041:13)
at https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:111:14
at https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:1084:6
at each (https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:39:19)
at Object.emit (https://sitregxxxtrial.hanatrial.ondemand.com/sap/watt//lib/requirejs/require.js:1083:5)

@gregorwolf
Copy link
Contributor Author

Unfortunately this messages when editing an .xsodata file are "normal" I learned to ignore them. As long as you can activate the .xsodata file at the end. Perhaps we should create an issue for the backend first and continue here as soon as the backend is fixed and the Jasmine tests are running.

@gregorwolf gregorwolf changed the title Selected date shows up as date - 1 day Date selected is saved as selected date minus 1 day Aug 21, 2016
@jpenninkhof
Copy link

Seen this many times. The only solution I know of so far is to add the timezone offset before you call the service to store the date:

var timezoneOffset = new Date().getTimezoneOffset();
object.date.setTime(object.date.getTime() - timezoneOffset);

@FiddleBe
Copy link

Oh actually, I've had that issue myself as well. With a PHP backend, I simply create a timestamp from the javascript W3C timestamp (which automatically converts the timezone to UTC).
then I still have to do some tweaking for mysql, which uses a different timestamp format.

Surely, HCP Java runtime should have something similar? or Maybe use the Node.js as server side processing?
http://stackoverflow.com/questions/4099862/convert-java-date-into-xml-date-format-and-vice-versa

@lemaiwo
Copy link
Contributor

lemaiwo commented Mar 28, 2017

I think it's fixed. I've added UTC:true. Can you validate this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants