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: 
WellerEE
Visitor

roDateTime

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
2 REPLIES 2
belltown
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
3/22/12
Thu March 22, 2012


According to the Component Reference Manual, I should get:


Mar
Thursday March 22, 2012
3/22/12
Thu
0 Kudos
renojim
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")
prints
Fri Mar 23, 2012

-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
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.