jhipster / jhipster-dotnetcore

JHipster.NET blueprint
Apache License 2.0
314 stars 93 forks source link

Date Issue on client application #373

Closed mark-mngoma closed 2 years ago

mark-mngoma commented 4 years ago

I have been testing the sample dotnet project and notice that the client app has an issue is saving dates previous to the one inputted on the form but it works well with postman. Is the issue in this line of code: if (!employee.id) { const today = moment().startOf('day'); employee.hireDate = today; } in the employee-update component?

mark-mngoma commented 4 years ago

I chose 2020-09-18 but api response payload gives 2020-09-17

nicolas63 commented 4 years ago

Our clients code is based on java version can you verify if the java application has the same bug ?

mark-mngoma commented 4 years ago

I have a java project running and it is fine, but I think the problem is within the dotnet client application neither java or dotnet server applications.

nicolas63 commented 4 years ago

The dotnet client (angular) is exactly the same than java version. Which version of jhipster is on your java project?

mark-mngoma commented 4 years ago

They are not exactly. I am actually testing this project: https://github.com/jhipster/jhipster-sample-app-dotnetcore

mark-mngoma commented 4 years ago

The java project is running version 5.4.2, which is working fine.

nicolas63 commented 4 years ago

This blueprint is base on jhipster 6.10.1

mark-mngoma commented 4 years ago

Yes it is, but the bug persists on this version as well as I am testing on the latest and it seems the date reverts a day back.

nicolas63 commented 4 years ago

Ok i think is link to https://github.com/jhipster/generator-jhipster/issues/11740

mark-mngoma commented 4 years ago

This issue is not happening on the Java project, only the dotnet project.

nicolas63 commented 4 years ago

Ok i will investigate this problem

mark-mngoma commented 4 years ago

Still an issue I am failing to resolve as I don't know whether the issue is how the date is parsed on the client application, because when I test on postman, everything works fine, so the issue is the client.

nicolas63 commented 4 years ago

Can you give me more information i can't reproduce this on my machine, can you give me jdl / jhipster version / your machine os ?

mark-mngoma commented 4 years ago

It's this repo:https://github.com/jhipster/jhipster-sample-app-dotnetcore that I am running on the latest version of Windows 10 and also on docker.

nicolas63 commented 4 years ago

you don't generate an application ? you use directly the sample ? ok can try to reproduce with the sample

mark-mngoma commented 4 years ago

Yes, I am using the sample project to reference the logic on the client application, especially when it comes to setting datepickers through moment.js as you're using it in the sample project.

mark-mngoma commented 4 years ago

I have a generated project, which I am referencing from the sample project.

nicolas63 commented 4 years ago

Everything in the example is generated with the generator. But ok I will try again to reproduce.

Thanks for your feedback.

mark-mngoma commented 4 years ago

Sure, please just working in doing a form post on the client to see the issue as it doesn't occur when testing with swagger or postman.

mark-mngoma commented 4 years ago

Any field with datetime

nicolas63 commented 4 years ago

I have try this but it's ok for me. Wich date format is on your os ?

mark-mngoma commented 4 years ago

Really? Does it not set to the date before? Like if you select 2020-06-04 then it persists as 2020-06-03?

My os datetime format is ddmmyyyy.

nicolas63 commented 4 years ago

I have the same format. Can you try to generate an application with the latest version on the master ? ( you need to clone and call npm link )

mark-mngoma commented 4 years ago

Using the jhipster generator and the jdl for entities or the demo repo?

nicolas63 commented 4 years ago

Generator and jdl or you can also use entity cli

nicolas63 commented 4 years ago

git clone cd repo npm link jhipster --blueprints dotnetcore jhipster entity YourEntity

mark-mngoma commented 4 years ago

I am still getting the same issue, I am testing with entity employee, field hireDate

mark-mngoma commented 4 years ago

I did everything here but I am still getting this issue. Please send me a screenshot of the process.

mark-mngoma commented 4 years ago

I am still receiving this issue on response payload it shows date as hireDate: 2020-09-22T22:00:00, but date chosen was: 2020-09-23T22:00:00

mark-mngoma commented 4 years ago

I am debugging and the timestamp is just being set at 22h00, I am not sure what config is handling this but it's on the client application, not the api.

mark-mngoma commented 4 years ago

It seems like this bug is some UTC parsing issue with Moment as it's happening with all the client applications from the dotnetcore generator.

nicolas63 commented 4 years ago

sorry for the delay, yes it's possible that the error comes from moment.js and UTC

mark-mngoma commented 4 years ago

I am thoroughly reading the moment documentation but if you have an idea on fixing the bug please give me an update when possible.

nicolas63 commented 4 years ago

in which timezone are you ?

mark-mngoma commented 4 years ago

SAST UTC+2

nicolas63 commented 4 years ago

Can you try to add options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; in newtonsoft options in MvcStartup.cs ?

mark-mngoma commented 4 years ago

I have added. Issue still persists as is

mark-mngoma commented 4 years ago

I am testing the Java project and it's doing the same thing. Any ideas of configuring moment() properly? Screenshot (137)

mark-mngoma commented 4 years ago

It's a weird issue, very difficult to debug where it's coming from.

mark-mngoma commented 4 years ago

But it is definitely an issue on client application parsing the date properly.

nicolas63 commented 4 years ago

if the bug il also on the java version can you open an issue on https://github.com/jhipster/generator-jhipster ?

check before if the issue is not already open

mark-mngoma commented 4 years ago

I managed to get this fixed but it would be great for you to look at it and fix it for future releases.

nicolas63 commented 4 years ago

@NtsikaMngoma how did you fix it ?

mark-mngoma commented 4 years ago

@NtsikaMngoma how did you fix it ? https://github.com/jhipster/generator-jhipster/issues/12577

nicolas63 commented 4 years ago

Ok but we need to take open this issue while the other issue is not resolve

mark-mngoma commented 4 years ago

It's the same issue, should I close it or will you close it once resolved?

mark-mngoma commented 4 years ago

Please have a look at this issue as I am battling to figure it out: https://github.com/jhipster/jhipster-dotnetcore/issues/378