#2548 JS: TimeZone not found: New_York

SlimerDude Mon 11 Jul 2016

I was trying some Fantom JS this weekend and found that when I tried to log.debug() I would receive:

sys::ParseErr: TimeZone not found: New_York

Which stems from TimeZone.js:

fan.sys.TimeZone.cur = function()
{
  // TODO
  if (fan.sys.TimeZone.m_cur == null)
    fan.sys.TimeZone.m_cur = fan.sys.TimeZone.fromStr("New_York");
  return fan.sys.TimeZone.m_cur;
}

Listing the available TimeZones only gave UTC and Rel:

echo(TimeZone.listNames)  // --> [UTC, Rel]

Am I missing some setup somewhere?

In the mean time I found that manually setting the current TimeZone to UTC in Javascript solves the problem. In Duvet this can be accomplished with:

htmlInjector.injectRequireScript(
  ["sys":"sys"], "fan.sys.TimeZone.m_cur = fan.sys.TimeZone.fromStr('UTC');"
)

brian Mon 11 Jul 2016

The design for timezones now expects the whole timezone database to be loaded which you can do by including etc/sys/tz.js into your page. Its provides a tight encoding of the full database which is lazily loaded by sys::TimeZone as timezones are used

SlimerDude Mon 11 Jul 2016

Okay, that sounds nice. I was just using: web::WebUtil.jsMain() to run Fantom code which doesn't mention this.

Any reason why the default JS time zone can't be changed to UTC? New York seems a bit arbitrary... and unsafe!

Login or Signup to reply.