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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 


I am having trouble with the roDateTime object.

I am trying to use the "short-month" format string in the asDateString function but when I do, I get the "long-date".

Any clues?
0 Kudos
Roku Guru

Re: roDateTime

It's generally easier to see what's going wrong if you post the code you're using.

EDIT: However, I think I see what's going on. "short-month" returns the same string as the "long-date" format, except it uses the first 3 characters of the month. That's not how it's described in the documentation, so I'd venture to say that it's a bug in the Roku firmware (or the documentation). The same applies to the "short-weekday" format.

To do what I think you're trying to do, you could do this:

dt = CreateObject ("roDateTime")
monthList = ["", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
print monthList [dt.GetMonth ()]

To further illustrate why I think there's a bug there, if I use this code:

dtNow = CreateObject ("roDateTime")
dtNow.Mark ()
dtNow.ToLocalTime ()

print dtNow.asDateString ("short-month")
print dtNow.asDateString ("long-date")
print dtNow.asDateString ("short-date")
print dtNow.asDateString ("short-weekday")

I get this result:

Thursday Mar 22, 2012
Thursday March 22, 2012
Thu March 22, 2012

According to the Component Reference Manual, I should get:

Thursday March 22, 2012
0 Kudos
Community Streaming Expert

Re: roDateTime

I seem to recall the documentation on asDateString being different in the past, but I could be mistaken. Anyway, I believe it always returns the full date. You can specify "short-month" and/or "short-weekday" to shorten the month and/or day. For example:
print dt.asDateString("short-monthshort-weekday")
Fri Mar 23, 2012

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