Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Where are DateTime properties normalized on server? #3158


User avatar
0
bilalhaidar created

Hi, While digging into the AbpFramework I saw the class below. Is this the place where DateTime properties coming from client are normalized to the current Clock Provider?

public class AbpApiDateTimeBinder : IModelBinder
    {
        public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
        {
            var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
            var date = value?.ConvertTo(typeof(DateTime?), CultureInfo.CurrentCulture) as DateTime?;
            if (date != null)
            {
                bindingContext.Model = Clock.Normalize(date.Value);
            }

            return true;
        }
    }

2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This is for WebApi, there are two more places,

    For MVC: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.Web.Mvc/Web/Mvc/ModelBinding/Binders/AbpMvcDateTimeBinder.cs">https://github.com/aspnetboilerplate/as ... eBinder.cs</a>

    For AspNet Core: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs">https://github.com/aspnetboilerplate/as ... lBinder.cs</a>

  • User Avatar
    0
    bilalhaidar created

    Thanks a lot :D