Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gloda query with date range

20 views
Skip to first unread message

Hermann D. Schimpf

unread,
May 7, 2013, 9:51:52 PM5/7/13
to
Hi everyone,
I have a trouble developing a add-on for thunderbird.
I make a query with Gloda but doesn't works.
This is a part of my code where I make the query:

let query = Gloda.newQuery(Gloda.NOUN_MESSAGE);

let yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);

query.dateRange(yesterday, new Date());

When it run I get an error saying "TypeError: aDate is undefined; File gloda.js [Line 1138]".
I googled but I can't solve this.
I have Thunderbird 17 on Ubuntu Linux 64bit.

Any help is welcomed
Thanks

Mark Filipak

unread,
May 8, 2013, 7:05:03 PM5/8/13
to Hermann D. Schimpf, dev-apps-t...@lists.mozilla.org
I don't know what Gloda is and I don't know the arguments for the
'query.dateRange' method, but I'll bet an integer between 1 and 31 is not what
'query.dateRange' wants. It probably wants a full 'ms since 1 January 1970
00:00:00' number. If so, I think you want to try this:

var today = new Date().getTime();
today = today.setTime(today - today % 86400000);
query.dateRange(today - 86400000, today);

Give me a PM and let me know how it works out.

Mark.
--
The Insect Hall of Fame:
Thunderbird Bug 121947 - 11 years and counting.

Mark Banner

unread,
May 9, 2013, 4:54:02 AM5/9/13
to
> On 2013/5/7 9:51 PM, Hermann D. Schimpf wrote:
>> Hi everyone,
>> I have a trouble developing a add-on for thunderbird.
>> I make a query with Gloda but doesn't works.
>> This is a part of my code where I make the query:
>>
>> let query = Gloda.newQuery(Gloda.NOUN_MESSAGE);
>>
>> let yesterday = new Date();
>> yesterday.setDate(yesterday.getDate() - 1);
>>
>> query.dateRange(yesterday, new Date());

I did a quick search through mxr (http://mxr.mozilla.org/comm-central),
the only instance I've found is here:

http://hg.mozilla.org/releases/comm-esr17/annotate/1834c9586d8f/mailnews/db/gloda/test/unit/base_query_messages.js#l423

which implies you need to make those arguments into an array, i.e.

query.dateRange([yesterday, new Date()]);

On 09/05/2013 00:05, Mark Filipak wrote:
> I don't know what Gloda is and I don't know the arguments for the
> 'query.dateRange' method, but I'll bet an integer between 1 and 31 is
> not what 'query.dateRange' wants. It probably wants a full 'ms since 1
> January 1970 00:00:00' number.

A quick google search and some tests in the Error Console, reveals that
the date calculation is correct:

http://stackoverflow.com/questions/5511323/javascript-yesterday

Mark

Andrew Sutherland

unread,
May 14, 2013, 1:58:28 AM5/14/13
to
On 05/09/2013 04:54 AM, Mark Banner wrote:
> which implies you need to make those arguments into an array, i.e.
>
> query.dateRange([yesterday, new Date()]);

bingo. That and other useful tidbits can be found at:
https://developer.mozilla.org/en-US/docs/Thunderbird/Creating_a_Gloda_message_query

Andrew
0 new messages