Your Digital Media Has Never Looked So Good

 
simranjit
Topic Author
Posts: 15
Joined: Thu Oct 20, 2016 4:28 am

ToISOString() return wrong date time

Tue Feb 12, 2019 3:58 am

Hi,

Working on time based application, when reset the device and launch our application instant, we are getting wrong date and time instead of current date and time.
date = CreateObject("roDateTime")
print date.ToISOString()


Output is "2019-01-09T02:59Z" instead of "2019-02-12T10:42Z", showing approximate 34 days previous static date every time.
But if we restart the device and launch the application after internet connection, then we are getting correct date and time.

Please suggest the solution for this problem.

Thanks in advance,
Simran 
 
renojim
** Valued Community Member **
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: ToISOString() return wrong date time

Tue Feb 12, 2019 12:15 pm

There is no solution. The box doesn't have a battery backed-up RTC. I doesn't know the correct date/time until it establishes an Internet connection and contacts an NTP server. If your app can't operate without the correct time, you either have to wait for Internet connection to be established or exit if the connection hasn't been established. You can't rely on roDateTime unless the box is able to contact the Roku NTP server.

-JT
 
destruk
Posts: 2720
Joined: Sat Dec 18, 2010 4:58 pm

Re: ToISOString() return wrong date time

Tue Feb 12, 2019 5:04 pm

Perhaps you can check for the date/time, and if it is the default date you receive when there isn't an internet connection available, simply not use the data and check it again later in the application.
Although why your device would require the internet but not be able to access the date/time server, sounds like a critical flaw in your internet routing service/gateway/proxy maybe?
 
simranjit
Topic Author
Posts: 15
Joined: Thu Oct 20, 2016 4:28 am

Re: ToISOString() return wrong date time

Wed Feb 13, 2019 9:33 pm

renojim wrote:
There is no solution.  The box doesn't have a battery backed-up RTC.  I doesn't know the correct date/time until it establishes an Internet connection and contacts an NTP server.  If your app can't operate without the correct time, you either have to wait for Internet connection to be established or exit if the connection hasn't been established.  You can't rely on roDateTime unless the box is able to contact the Roku NTP server.

-JT

Thanks 
 
simranjit
Topic Author
Posts: 15
Joined: Thu Oct 20, 2016 4:28 am

Re: ToISOString() return wrong date time

Wed Feb 13, 2019 9:35 pm

destruk wrote:
Perhaps you can check for the date/time, and if it is the default date you receive when there isn't an internet connection available, simply not use the data and check it again later in the application.
Although why your device would require the internet but not be able to access the date/time server, sounds like a critical flaw in your internet routing service/gateway/proxy maybe?

Thanks, we will look into internet routing service.
 
destruk
Posts: 2720
Joined: Sat Dec 18, 2010 4:58 pm

Re: ToISOString() return wrong date time

Thu Feb 14, 2019 11:12 am

If your content list json or xml is generated in realtime on the server via a script, you could have the server provide the time in that file when it is sent to the Roku (as a time from epoch in seconds), or simply run a php script on the server to return the data separately, and then you could start a timer service on the Roku and add both together to get the time without using the Roku time server.  Just another 'solution'.

Who is online

Users browsing this forum: No registered users and 5 guests