Gloda query with date range

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Gloda query with date range

Hermann D. Schimpf
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
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Gloda query with date range

Mark Filipak
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());
>
> 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

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.
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Gloda query with date range

Mark Banner-4
In reply to this post by Hermann D. Schimpf
> 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
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Gloda query with date range

Andrew Sutherland-3
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
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird