Base solution for your next web application
Open Closed

Date Input using date-range-picker and UTC clock provider #4574


User avatar
0
JapNolt created

We are using ASP.Net Core and Angular project. We've set the project to use the UTC Clock Provider. The examples I'm going to give use the built-in Audit Logs. I've patterned some of my other data grids and filters off of this and they're suffering the same problem.

All audit logs in the db is being saved as UTC time. When shown in the Angular UI, the audit logs are showing correctly in the TimeZone that the user has selected (in my case EST, which is GMT -5). This is all good. But when the user selects a date range to filter the audit logs, the dates sent are the "local time".

So if the user selects to show audit logs from 2018/01/26, the filters are sent to the backend as 2018/01/26 00:00:00 - 2018/01/26 23:59:59. When the data is returned, there could be some audit logs with a date of 2016/01/25 which is not what the user would expect. Instead, the date range that is sent to the app service should be in UTC which in my case would be 2018/01/25 19:00:00 - 2018/01/26 18:59:59.

Am I missing some config on the Angular side or is the date range picker not being initialized correctly with the time zone offset?


8 Answer(s)
  • User Avatar
    0
    [email protected] created

    Have the same problem - All dates are being display correctly after setting the timezone but the searches are not aligned as the data is stored in UTC and the search dates are in the selected timezone

    thanks for your help

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have tested this scenario and in my case, filter dates on audit logs page is send to server in the user's selected timezone. I'm attaching a screenshot with selected values. Can you write back if this is not the case you are talking about ?

  • User Avatar
    0
    JapNolt created

    @ismcagdas My experience is the same as yours. Hmmmmm.....Ahhh, but the query inputs in the app service come in as "local time", which are then executed as is.

    BTW, in my original post, my offset calculations were incorrect. Your UI is sending the correct query parameter values but the backend is converting them back to local. Instead they shouldn't be converted back to local but should remain in UTC.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @JapNolt can you check two things ?

    1. What is the value of Clock.Provider when you debug audit log app service ?
    2. What is the value of Kind property for your input's startDate when you debug the code ?

    Also, it would be great if you can share the string value of your datetime when you check it on Chrome's network tab.

    Thanks.

  • User Avatar
    0
    JapNolt created

    Clock.Provider.Kind = UTC input.StartDate.Kind = Local

  • User Avatar
    0
    ismcagdas created
    Support Team

    @JapNolt it shows there is a bug in ABP framework. Is it possible for you to share your project with us via email ? It will be easier to reproduce this problem for us.

  • User Avatar
    0
    JapNolt created

    @ismcagdas

    I re-downloaded a new demo project off the AspNetZero site and it worked correctly. So I compared the Abp dll versions and the new dll were at 3.3.0 in the sample whereas my project was at 3.2.5. I've upgraded those dll's in my project and the problem went away. So problem resolved by updating Abp Framework dlls.

    BTW, is there a blog, email list, or something like that so I can keep track when new versions of the project are released?

  • User Avatar
    0
    ismcagdas created
    Support Team

    @JapNolt Thanks a lot for your feedback. We are sending emails to our customers for each release of AspNet Zero.

    If you want to follow ABP framework as well, you can watch <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate">https://github.com/aspnetboilerplate/aspnetboilerplate</a>.