XeroAPI / xero-php-oauth2

Xero PHP SDK for oAuth 2 generated from Xero API OpenAPI Spec 3.0
MIT License
90 stars 64 forks source link

Employee::getDateOfBirthAsDate not converting dates prior to 1970 correctly #272

Open nglasl opened 2 years ago

nglasl commented 2 years ago

SDK you're using:

Describe the bug When retrieving a list of employees, we noticed some of them coming back with the incorrect date of birth, more specifically when their date of birth was prior to 1970.

To Reproduce Steps to reproduce the behavior:

  1. Use "DateOfBirth": "/Date(-310867200000+0000)/", when calling Employee::getDateOfBirthAsDate.
  2. This will return 1979, but it should actually return 1960.
  3. If you use Date::toDateTime from https://github.com/webapix/dot-net-json-date-formatter this will actually convert to 1960 correctly.
  4. I tried updating to the latest version of the library, but this still uses the same logic and gives the incorrect date.

Expected behavior This date should be converted to 1960 and not 1979.

Screenshots N/A

Additional context The logic inside StringUtil::convertStringToDate and StringUtil::convertStringToDateTime just need to be updated to something similar to the other library (perhaps even introducing that library as a dependency).