Some more questions on Dates / Intervals

Nagy Gabor <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <20210327113428.14295dc0@Dell>
Dear Ralf,

The good news is that I have only one question left. :) (Or at least now
I think I implemented everything I wanted in my tracker.)

> On Tue, Mar 23, 2021 at 02:25:49AM +0100, Nagy Gabor wrote:
> > When I do not know how to do something, I always look at working
> > examples first. (Now I am trying to learn how to use the Date() and
> > Interval() machinery... Atm I do not really know how can use Date()
> > "arithmetic" and comparison in the web interface (it is OK in an
> > extension). I do not even know how to filter tasks with
> > "deadline <= 2021.03.24", for example. I suspect I have to use
> > filter_sql.)  
> 
> You can subtract Date objects to yield an Interval. And you can add an
> Interval to a Date. You also can compare dates (and Intervals).


How can I use this date/interval arithmetic on checking deadline
property of an issue item? For example, how can I test "context/deadline
< .+3d"? (I want to color these issues red in the issue class view.) 
How can I create the Date object ".+3d" in the html templates? Exact
tal:condition etc. would be appreciated. :) OK, I can do this by writing
an extension (util) and import Roundup's date module, but I guess there
is a simpler way I missed.

I figured out the followings so far:

1. [+ BUG?] The now() method of DateHTMLProperty can be used to create a
Date() object of the form ".+3d":

But a strange thing happens here: In the same HTML template,

python:context.deadline.now().pretty('%Y-%m-%d.%H:%M')

gives 2021-03-27.11:05, but

python:context.deadline.now('+3d').pretty('%Y-%m-%d.%H:%M')

gives 2021-03-30.12:05.

I guess we have a local time issue here... (I could completely turn off
that, if I could, both the servers and the users are in Hungary, the
server's local time would be perfect.)

2. But it seems

tal:condition="python: context.deadline < context.deadline.now('+3d')"

works as expected.

3. But how can I create custom Date object? In fact, I want to check that
"deadline <= 2021-03-30.23:59:59" not "deadline <= 2021-03-30.11:05".
And many other situations can occur when I want to define a custom date.
(I observed that dates in standard form can be compared as a string. That
is always an ultimate solution: Using .pretty(), I can easily create the 
string "2021-03-30.23:59:59" from the output of now()).

Regards,
Gábor

> As John has already pointed out the query syntax is described, I
> prefer the geek syntax, with a ';' as the separator. So searching for
> a range of dates is done by specifying a range (start or end may be
> omitted), e.g. '.-5w;.+5w' will search for all dates in the range +/-
> 5 weeks from now. As you may have noticed, '.' is special and denotes
> the current date/time. New is that you can combine multiple ranges
> with ',' as a separator in a query, I'm not sure this is documented
> fully yet. And '-' is special and matches an empty date (NULL in the
> database, None in python). So if you have an end-date and you're
> searching for all items that have either an empty end-date or None
> you would use ';.,-' as the query string .-)
> 
> Ralf


_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.