jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2010
03:33 PM
roDateTime...
I see there is a function to set the time to an arbitrary ISO8601 time (now my roku seems to think its January!), but what I need is to get today's date and time in iso8601 format as a string... and also an arbitrary date in the past...
- Joel
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
15 REPLIES 15

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2010
04:08 PM
Re: roDateTime...
You'll need to build it yourself. There is no built in method.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2010
04:11 PM
Re: roDateTime...
I don't think there's a function, but it should be trivial to write your own. Once you have that you you can set an roDateTime object to an arbitrary timestamp and then use your function to get the ISO formatted string. By the way, there's no way to set the time/date of the box itself, just the time/date of an roDateTime object.
-JT
-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.
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.
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
01:52 AM
Re: roDateTime...
Yeah, trivial to you!
🙂
🙂
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
02:02 AM
Re: roDateTime...
Actually, seems to me that date calculations are insanely complex - for instance, how do you know what the day and month is for an arbitrary today minus x days? You have to calculate leap years, months with 30 days instead of 31 and February which is shorter every four years, plus years are adjusted due to variations in the earths orbit by NIST,aren't they?
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
jbrave
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
03:20 AM
Re: roDateTime...
Yeah, I can't figure it out. if I have 2010-10-19 - X number of days how do I come up with the exact year month and day? Seems like it would need lots of lookup tables and such to be able to handle this even for a short time range, and unless I'm misunderstandin roDAteTime, it doesn't do that... or does it?
What does "Initialize the date/time value using the number of seconds from epoch" mean in english?
Essentially, I need to pass in two dates to get back the data I need - today, and today - X formatted as "YYYY-MM-DD HH:MM:SS" so I really have to be able to give the correct info, and I'm not seeing how to do this at all.
- Joel
What does "Initialize the date/time value using the number of seconds from epoch" mean in english?
Essentially, I need to pass in two dates to get back the data I need - today, and today - X formatted as "YYYY-MM-DD HH:MM:SS" so I really have to be able to give the correct info, and I'm not seeing how to do this at all.
- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
03:30 AM
Re: roDateTime...
nowDate = CreateObject("roDateTime")
nowDate.Mark()
calcDateSeconds = nowDate.AsSeconds() - (numDays * 60 *60 * 24) 'number of days * seconds in minute * minutes in hour * hours in day
calcDate = CreateObject("roDateTime")
calcDate.FromSeconds(calcDateSeconds)
calcDate.ToLocalTime()
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
04:45 AM
Re: roDateTime...
"jbrave" wrote:
What does "Initialize the date/time value using the number of seconds from epoch" mean in english?
The Unix epoch was the beginning of the day on January 1, 1970 UTC or 1970-01-01T00:00:00Z ISO 8601. So, 1:00am on 1/1/1970 would have a Unix timestamp of 3600. Right now it's 1287574264 seconds since the epoch. 1287574264/3600/24 gives 14902.5 days since the epoch. All calculations using the built-in functions should handle things like leap years, but I doubt they account for leap seconds. There's a long discussion of Unix time and leap seconds here if you're interested.
-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.
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.
GandK-Geoff
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
10:35 AM
Re: roDateTime...
"TheEndless" wrote:nowDate = CreateObject("roDateTime")
nowDate.Mark()
calcDateSeconds = nowDate.AsSeconds() - (numDays * 60 *60 * 24) 'number of days * seconds in minute * minutes in hour * hours in day
calcDate = CreateObject("roDateTime")
calcDate.FromSeconds(calcDateSeconds)
calcDate.ToLocalTime()
Just a note that this of course doesn't handle daylight savings time changes and suchlike, which means you can only trust it to get the right date, not time -- and then only far enough away from midnight -- but correct time for the "date in the past" may not be an actual requirement.
Truly correct handling of time requires a LOT of code and data. Most likely more than we want to carry around in a channel package ....

gonzotek
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2010
12:12 PM
Re: roDateTime...
"GandK-Geoff" wrote:"TheEndless" wrote:nowDate = CreateObject("roDateTime")
nowDate.Mark()
calcDateSeconds = nowDate.AsSeconds() - (numDays * 60 *60 * 24) 'number of days * seconds in minute * minutes in hour * hours in day
calcDate = CreateObject("roDateTime")
calcDate.FromSeconds(calcDateSeconds)
calcDate.ToLocalTime()
Just a note that this of course doesn't handle daylight savings time changes and suchlike, which means you can only trust it to get the right date, not time -- and then only far enough away from midnight -- but correct time for the "date in the past" may not be an actual requirement.
Truly correct handling of time requires a LOT of code and data. Most likely more than we want to carry around in a channel package ....
It'd be nice if someone like NIST would provide an api or protocol to definitively handle these kinds of calculations. So for example:
"http://server/calc?StartDate=20091020220101GMT-5&EndDate=20101021090323GMT-5&format=xml"
would return some xml with the properly calculated interval between the two dates. Or something along those lines. I've had to deal with date calculations before, and I agree they get hairy fast. I looked around for somebody providing something like this before posting: I thought for sure someone like Google, NIST, Yahoo, or MS would already be providing this service, but apparently not. There are lots of sites that will do the calcuations in javascript or another language and just display it back to you, but then you'd have to scrape the results if you wanted to use them in a Roku channel.
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com