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?

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

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