Base solution for your next web application
Open Closed

moment vs luxon #10384


User avatar
0
mahendra created

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • What is your product version? 10.3
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .Net Core

Hi Expert,

There is a CreateOrUpdateDto having Datetime property say CreationTime. Return a NEW instance of this Dto From AppService. Once the Dto returned from AppService, evaluate the following in Chrome Developer Console and below is the result:

`JSON.stringify(result.creationTime)

//While using moment 0001-01-01T00:00:00.000Z

//While using luxon 0001-12-31T23:58:45.000+8759:58`

While posting this Dto back to appService without any change in the above Dto, in case of moment it saves the creationTime correctly but in case of luxon the backend method is not getting called and complain that the data in the creationTime is not valid.

Please advise...

Regards, Mahendra


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

    Hi @mahendra I could not reproduce it. Can you please share your app service and angular codes?

    Here is my test code: AppService

    public DateTime GetDate()
    {
        return default;
    }
    
    public void SetDate(DateTime dateTime)
    {
        var date = dateTime;
    }
    

    angular

    constructor(
        private _testServiceProxy: TestServiceProxy
    ) {
        //...
    }
    
    ngOnInit(): void {
        this._testServiceProxy.getDate().subscribe(dateResult => {
            this._testServiceProxy.setDate(dateResult).subscribe(() => {
            })
        });
    }
    
  • User Avatar
    0
    mahendra created

    Hi,

    Don't return the datetime directly. Let me mention the steps again.

    1. Create a Dto having a property of type Datetime
    2. Create a AppService and simply create and return the new object of above Dto from the AppService.
    3. Check the returned Dto in angular. Here, you will see different value of datetime property in case using moment and luxon.
  • User Avatar
    0
    musa.demir created

    Hi @mahendra

    I get the same result. Can you please share your test case?