0

Will Date() be reliable on a connected TV?

I have date info I'll need to show. Will var now = new Date() be accurate?

by
10 Replies
  • QUOTE (kpmartinatdci @ Dec 7 2009, 07:33 AM) <{POST_SNAPBACK}>
    I have date info I'll need to show. Will var now = new Date() be accurate?

    See the following posts:

    http://developer.yahoo.net/forum/index.php...tart=#entry8598
    http://developer.yahoo.net/forum/index.php...tart=#entry4696
    0
  • Yes... sorry, I asked poorly. I do know about that.

    I mean, once I have a nice, valid Date object set up, when I do aDate.getHour() can I count on what I get?

    Backstory: My data interchange format for dates is ISO 8601:2004 so we have a function that reliably instantiates a Date object based on that time taking into account timezone offset. Once a Date object is instantiated, normally something like aDate.getHour() returns an hour based on the instantiated date as represented by the user's local settings. So, for instance, I'll instantiate a time outside of my timezone and it will know what that means to me where I am:

    > var d = new Date()
    < undefined
    > d.setISO8601('2009-12-07T10:00:00-0400')
    < The Date obj thinks it's: Mon Dec 07 2009 08:00:00 GMT-0600 (CST)

    Will the Yahoo TV Widget platform do the same, returning what that time means based on the user's settings/locations/whatever?
    0
  • QUOTE (kpmartinatdci @ Dec 7 2009, 08:29 AM) <{POST_SNAPBACK}>
    Yes... sorry, I asked poorly. I do know about that.

    I mean, once I have a nice, valid Date object set up, when I do aDate.getHour() can I count on what I get?

    Backstory: My data interchange format for dates is ISO 8601:2004 so we have a function that reliably instantiates a Date object based on that time taking into account timezone offset. Once a Date object is instantiated, normally something like aDate.getHour() returns an hour based on the instantiated date as represented by the user's local settings. So, for instance, I'll instantiate a time outside of my timezone and it will know what that means to me where I am:

    > var d = new Date()
    < undefined
    > d.setISO8601('2009-12-07T10:00:00-0400')
    < The Date obj thinks it's: Mon Dec 07 2009 08:00:00 GMT-0600 (CST)

    Will the Yahoo TV Widget platform do the same, returning what that time means based on the user's settings/locations/whatever?


    No the widget engine will always use GMT time regardless of user settings.
    0
  • QUOTE (Mike R. @ Dec 8 2009, 04:57 PM) <{POST_SNAPBACK}>
    No the widget engine will always use GMT time regardless of user settings.


    That's not entirely true. There is no "user settings" for timezone, so obviously the engine always uses GMT, not because it ignores something the user set. :)-Jeremy
    0
  • Yeah when I was first testing this, I kind of hoped if the user set their zipcode you'd be able to set the timezone ;-)

    I guess, can you access the zipcode setting? Maybe bounce that off a webservice to get the users timezone?
    0
  • Thanks for the responses.

    FYI, there is a spot for both ZIP code and time zone in the settings.
    0
  • QUOTE (kpmartinatdci @ Dec 10 2009, 10:30 AM) <{POST_SNAPBACK}>
    FYI, there is a spot for both ZIP code and time zone in the settings.


    Not that other widgets can access. So again, my point stands. :)-Jeremy
    0
  • QUOTE (Jeremy Johnstone @ Dec 10 2009, 12:47 PM) <{POST_SNAPBACK}>
    Not that other widgets can access. So again, my point stands. :)Or... at the same moment, if var dateObj = new Date (getRealTime() * 1000) were run on a device in New York and a device in California, would there be any difference between the two dateObjs? It sounds like you're saying dateObj.getHours() will return the same thing in both instances.
    0
  • Any feedback on this? These Date objects are like Jello.
    0
  • getRealTime returns UTC (As would any method returning a unix epoch).

    Nothing stops you from asking the user for their timezone in your widget and then using the Date methods to adjust accordingly.

    -Jeremy
    0

Recent Posts

in General - Yahoo! TV Widgets