Converting Unix Timestamp to Date and Displaying it on LineChart issue

Dear all,
My LineChart displays the next 7 days high-low temperatures. While Y-axis indicates temperature records, X-axis indicates the dates. The data is coming from OpenWeatherRest Api and it has a parameter list.dt returning a value like this:

1568977200

which is a time of data forecasted as described in their docs. After googling I found out it is in UnixTime so I use built-in function to convert it to Date and use the result to add my DataPoint.

AddSeconds(NewDate(1970, 1, 1),LongIntegerToInteger(LoadDashboard.DailyItem.Current.Dt))

At first glance everything looks all right:

because today is December 4th yet in USA. However when I choose location lets say in Europe :

the date become December 5th :) and it is same for all other locations.

As far as I have observed the X axis moves dynamically. It is 18-19 pm in Europe and the day soon is going finish, and therefore the Chart API has already removed the current day and displays next day on graph anymore. On the other hand at the moment in Atlanta apparently it is 11 am and the date 4 Dec is still displayed on graph. For this reason I suppose rather than calculation it is a graph issue.
Do you have any idea how to correct the X axis so that it doesn't confuse with the information displayed on it. Although the first point located on X axis may indicate the correct date, it may really mislead just because it's date not written anymore especially for locations where it is close to midnight :)

Here is also chart properties:

Many many thanks ! :)

Hi Gulbala,

I don't really understand what your question is, if the api decides to return 7 days from the 5th onwards instead of the 4th, because it is already later in that timezone, there's not much you can do about it.

Dorine

The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC. 


so, you will need to move the hours to reach your timezone. At least, this is my guess.

Hi Gulbala,

I don't really understand what your question is, if the api decides to return 7 days from the 5th onwards instead of the 4th, because it is already later in that timezone, there's not much you can do about it.

Dorine

Hi Dorine, I see.. Thank you for the clarification :)

mvp_badge
MVP

Hi Gulbala,

Though Dorine already gave you the correct answer probably, have you checked the actual values that are sent from the API? If you request data for the Netherlands, and you receive timestamps that are higher than those for the US, it's not a surprise the dates might differ?

That said, be aware that the NewDate() Function creates a Date according to the local timezone, so adding a number of seconds will return a Date Time that's valid to the local time zone, not UTC. OutSystems cloud servers run on UTC, so you should be safe if you use them, but in case you use an On Premise installation, you could get nasty side-effects.

Hi Kilian , thanks for sharing further insights into the topic 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.