lookfirst / bittrex-typescript

Sorry for yet another client, I didn't like what else was out there

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Time not correctly parsing UTC

rightisleft opened this issue · comments

When i make a raw call using curl to:
https://bittrex.com/api/v1.1/public/getmarkethistory?market=USDT-BTC

I get the following:

{
    "success": true,
    "message": "",
    "result": [
        {
            "Id": 31205548,
            "TimeStamp": "2017-12-18T03:52:51.587",
            "Quantity": 0.00331552,
            "Price": 18473,
            "Total": 61.24760096,
            "FillType": "FILL",
            "OrderType": "BUY"
        },
        {
            "Id": 31205547,
            "TimeStamp": "2017-12-18T03:52:51.587",
            "Quantity": 0.00259669,
            "Price": 18470,
            "Total": 47.9608643,
            "FillType": "PARTIAL_FILL",
            "OrderType": "BUY"
        }...

However, when i look at the data coming back from:

this.bittrex.marketHistory(markets);

It's converting the dates into a different timezone.

2017-12-18T08:52:40.997Z
2017-12-18T08:52:40.997Z
2017-12-18T08:52:40.997Z
2017-12-18T08:52:40.997Z
2017-12-18T08:52:40.997Z
2017-12-18T08:52:38.840Z
2017-12-18T08:52:38.840Z
2017-12-18T08:52:37.120Z
2017-12-18T08:52:27.963Z
2017-12-18T08:52:22.260Z
2017-12-18T08:52:20.150Z

Given that 3:52:51.587 is UTC time and 10:52:51.587 is Local Time, when i call marketHistory, then it should be represented either in pure UTC or Local Time.

Sure. Want to submit a PR?

I don't know whats causing it yet. I was looking the JsonProperty implementation, but it looks to be to spec.

Fixed with above PR. Thanks for your contribution.

@lookfirst
The following should maintain UTC time new Date(date + 'Z');

Essentially you're passing the time you get from the api "2017-12-18T03:52:51.587" and appending "Z" which tells the Date object to keep UTC time.

No need to use Moment.

@harry-sm Sure, I always hate more dependencies... PR that baby... =)