Integrating datejs

130 views
Skip to first unread message

tdk

unread,
Jul 13, 2011, 11:08:49 AM7/13/11
to Google Web Toolkit
Battling with timezones in my app I come across the datejs project
(datejs.com).
Is anybody out there who can help me integrating this stuff in my GWT
(2.3.0) project?

I followed the "Getting started" examples but executing anything
described therein results in errors like "undefined" in Firebug.

(Yes, I loaded date.js from SVN).

Any help/hints greatly appreciated

Thomas Broyer

unread,
Jul 13, 2011, 11:22:07 AM7/13/11
to google-we...@googlegroups.com
Are you using $wnd.Date to access the "enhanced" Date object? Also, how are you loading the date.js script in your app?

FYI, searching for "datejs gwt" on Google leads to http://code.google.com/p/kiyaa/wiki/Modules which already provides a GWT wrapper for DateJS.

tdk

unread,
Jul 14, 2011, 1:56:04 AM7/14/11
to Google Web Toolkit


On 13 Jul., 17:22, Thomas Broyer <t.bro...@gmail.com> wrote:
> Are you using $wnd.Date to access the "enhanced" Date object?
yes, I found this valuable hint in one of your posts! Right now I'm
trying the examples mentioned in "Getting started" and even they don't
work.

> Also, how are you loading the date.js script in your app?
I have added the loading in my initial .html File. There I evaluate
the locale and then load the corresponding date-XXX.js File:

document.write("<script type=\"text/javascript\" src=\'dates/
core.js\'></script>")
document.write("<script type=\"text/javascript\" src=\'dates/
date-" + locale.replace("_", "-", "g") + ".js\'></script>")
document.write("<script type=\"text/javascript\" src=\'dates/
extras.js\'></script>")

In Firebug I can see that the correct datejs files are loaded
successfully so the stuff should be available....

> Seehttp://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI...(if
> you haven't already)
check, done that, been there, ...

> FYI, searching for "datejs gwt" on Google leads tohttp://code.google.com/p/kiyaa/wiki/Moduleswhich already provides a GWT
> wrapper for DateJS.
I had seen this but didn't have a closer look what it is. I'll check
it out...

tdk

unread,
Jul 14, 2011, 2:56:11 AM7/14/11
to Google Web Toolkit


On 13 Jul., 17:22, Thomas Broyer <t.bro...@gmail.com> wrote:
> FYI, searching for "datejs gwt" on Google leads tohttp://code.google.com/p/kiyaa/wiki/Moduleswhich already provides a GWT
> wrapper for DateJS.

this no good, it doesn't even compile. It inherits stuff that isn't
part of the jar file.
I just copied the DateJs.java class into my project, but using it
fails with a JavaScript exception:

com.google.gwt.core.client.JavaScriptException: (TypeError):
this[16908544].clearTime is not a function

This happens when I do a DateJS.today().getTimezone().

I had this problem too when using the stuff without a wrapper...

Thomas Broyer

unread,
Jul 14, 2011, 6:38:04 AM7/14/11
to google-we...@googlegroups.com
Given that DateJS changes the built-in Date object, I wouldn't be surprised that it doesn't work cross-window/cross-frame (changing built-in types is considered bad practice anyway). Using <add-linker name="xs" /> (beware: deprecated) might be the only workaround.

tdk

unread,
Jul 14, 2011, 8:12:43 AM7/14/11
to Google Web Toolkit
thanx for helping, I've given up on it, too much hassle and I don't
think it's worth it for what I need...
Reply all
Reply to author
Forward
0 new messages