Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Wrapper libraries >

C# SDK Invoice.Date is a DateTime with Kind = Local?

Started by Dylan Nicholson -   in Wrapper libraries

The C# SDK defines the Invoice.Date and DueDate types as DateTime, and in the JSON returned by the Xero web API it's , e.g. "Invoices": { "DateString": "2019-02-04T00:00:00", "Date": "/Date(1549238400000+0000)/", "DueDateString": "2019-02-28T00:00:00", "DueDate": "/Date(1551312000000+0000)/",

This very obviously specifies that the DateTime's are UTC, but Invoice.Date.Kind and Invoice.DueDate.Kind are "Local", and when I do ".ToUniversalTime()" they get converted according to the timezone of the machine the code is running on.
This effectively means we end up displaying the due date of the invoice as off-by-1.
Is this just a bug in the C# SDK and can we just assume the Date/DueDate *are* always in UTC, despite the Kind being Local?



(PS is there a straightforward way with the C# library to grab the raw JSON string returned? I'd prefer to parse it myself with JSON.NET which doesn't have this problem)