Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
renojim
Community Streaming Expert

roDateTime fromISO8601String

I'm trying to initialize an roDateTime object from an ISO8601 date/time string. From the Roku DVP Component Reference:

Void fromISO8601String(String dateString) 
• Initialize the date/time using a string in the ISO8601 format. For example “01-01-2009T01:00:00.000”

The first thing to note is that the example does not follow the ISO8601 standard, it should be "2009-01-01T01:00:00.000". But, that doesn't work either. I've tried every possibility of moving the year around, with and without fractional seconds, with and without timezone offsets, etc., but the following code always shows that the date/time object never changes:


dt = CreateObject("roDateTime")
print dt.asSeconds()
dt.fromISO8601String("2009-01-01T01:00:00.000")
print dt.asSeconds()

I can change the value using the fromSeconds() function, but not the fromISO8601String() function.

Have I just not stumbled upon the magic string to make the function happy, or is it safe to say that this isn't really implemented even though it's in the documentation?

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
5 REPLIES 5
nowhereman
Visitor

Re: roDateTime fromISO8601String

"renojim" wrote:
Have I just not stumbled upon the magic string to make the function happy, or is it safe to say that this isn't really implemented even though it's in the documentation?

-JT


I spent some time a while back trying to use this function and had the same results. I never did find a string that worked with it.
twitter:nowhereman
http://www.thenowhereman.com/roku
http://www.thenowhereman.com/netflix
0 Kudos
RokuKevin
Visitor

Re: roDateTime fromISO8601String

This is indeed a bug.... The roDateTime.fromISO8601String() method is not actually accepting ISO8601 strings. We are not recognizing the "T" in the example above (or any other letters eg "Z" in the iso8601 string)

If you try to initialize using your code above, but replacing the "T" with a "-" you will get better results.

dt = CreateObject("roDateTime")
print dt.asSeconds()
dt.fromISO8601String("2009-01-01-01:00:00.000")
print dt.asSeconds()

We will fix this to better support ISO8601 strings in a future release. For now, only use date strings like the format above without letters in it.

--Kevin
0 Kudos
renojim
Community Streaming Expert

Re: roDateTime fromISO8601String

Thanks, that did it.

Well... I take it back. Entering the string as "2010-04-26-01:01:01.000" does change the value, but the new value is off by more than 7 million seconds. Changing the time doesn't affect the value either and in fact the time portion of the string can be left off completely.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
RokuKevin
Visitor

Re: roDateTime fromISO8601String

Try strings like:

"2010-04-26 00:00:00.000"
"2010-04-26 16:45:00.000"
0 Kudos
renojim
Community Streaming Expert

Re: roDateTime fromISO8601String

Ahh... that was it! And I thought I tried every combination of date and time.

Now if I could just remember why I was looking into this in the first place...

Thanks again,
-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.