Base solution for your next web application
Open Closed

DatePickerLuxonModifierDirective error? #9885


User avatar
0
ignasiclos created

In the DatePickerLuxonModifierDirective directive, it is returning a Javascript Date, shouldn't it be returning a Luxon DateTime?

Otherwise It's getting a luxon date and returning a JS Date?


5 Answer(s)
  • User Avatar
    0
    musa.demir created

    That part of the code just subscribes to normal datepicker's change event to make sure it only emits date change when the value is acceptable. Then it parses that value to luxon datetime on ngOnChanges and return it as a Datetime. See: https://github.com/aspnetzero/aspnet-zero-core/blob/ad8ca76f2aec5989e4ee9757a378c8d152c2a0ee/angular/src/shared/utils/date-time/date-picker-luxon-modifier.directive.ts#L48.

    Is it work incorrectly on your app? If it is, could you please check your implementation: https://github.com/aspnetzero/aspnet-zero-core/blob/6839babe2d808b1e5cde9e0c05fbc8f1b6f87310/angular/src/app/admin/demo-ui-components/demo-ui-date-time.component.html#L14-L22. You should use [(date)] not ngmodel

  • User Avatar
    0
    ignasiclos created

    This is my implementation :

    Where

    Without my modification, open date becomes a Js date and not a luxon date anymore.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @ignasiclos

    The DatePicker we are using requires a JS Date, so that's why the related directive is returning a JS Date. When you send your model to server, Angular app handles the JS dates as well. Did you have a problem regarding to this ?

  • User Avatar
    0
    ignasiclos created

    Yes,

    The problem It is not possible to have a luxon date variable binded two way to a bsTimepicker, because it is converted back to a js dateby the directive as it is out of the box.

    On the other hand, I've tried to change swagger date format back to moment, to keep compatibility with the I wrote for earlier versions of Asp.net Zero, but the angular applications stop compiling because all the dates have been converted to luxon.

    So, to be able to migrate < 10 versionsto version 10 I'll need to updte all the dates to Luxon.

    Am I right? Thanks!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    As I can see, TimePicker is also requires a JS date, see https://valor-software.com/ngx-bootstrap/#/timepicker#api-reference. This shouldn't be a problem.

    So, to be able to migrate < 10 versionsto version 10 I'll need to updte all the dates to Luxon. > Am I right?

    Yes, but this is valid for moment usages in your code only. We enhanced the https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/app/shared/common/timing/date-time.service.ts class to handle DateTime value conversions. So, you can use this class in your project and if you want to switch to moment or any other library in the future, you only need to change its content.

    Are you getting a specific error with your bsTimepicker ? If so, could you share it ?

    Thanks,