Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
squirreltown
Level 8

datetime(solved)

I know i'm missing something silly but can't see it.

thisclock = createObject("roDateTime")
thisclock.tolocalTime()



This is producing GMT time in 24hour mode. The roku is set to 12 hour.
So right now its 5pm (MST) and thisclock.GetHours() is reading 23

Thanks
Kinetics Screensavers
0 Kudos
3 Replies
renojim
Level 8

Re: datetime

At what point are you looking at thisclock.GetHours()? It works for me if I print thisclock.GetHours() right after your thisclock.toLocalTime() statement. If you call thisclock.Mark() at some later point, you'll have to call thisclock.toLocalTime() again. Also, GetHours() will always return a number between 0 and 23 inclusive.

-JT
0 Kudos
squirreltown
Level 8

Re: datetime

"renojim" wrote:
At what point are you looking at thisclock.GetHours()? It works for me if I print thisclock.GetHours() right after your thisclock.toLocalTime() statement. If you call thisclock.Mark() at some later point, you'll have to call thisclock.toLocalTime() again. Also, GetHours() will always return a number between 0 and 23 inclusive.

-JT



Thank you. I knew it was simple. I was calling local time before the while loop and then only mark during the loop. (floating screensaver clock)
Kinetics Screensavers
0 Kudos
EnTerr
Level 8

Re: datetime(solved)

"toLocalTime()" is better to think as "addTimeZone()" - that's all it does.

Say player is set as being on the west coast (PST = GMT-8), then each call will subtract 8 hours (make that 7 since this week) from the time value. Repeated calls will keep subtracting more hours repeatedly (there is a mathemagical warning about non-idempotence). roDateTime does not keep internal flag if that's local or universal timestamp, the function is just a single-direction mutator
0 Kudos