Fixing datime and working with it

21 views
Skip to first unread message

hayri

unread,
Aug 12, 2010, 9:56:18 AM8/12/10
to ETALIS
Hi everyone, I have two questions about datime method (may I call it a
method at all?).

1) The datime is giving me the wrong time. It's 15:40 right now bu
it's showing 13:40. How and where to fix it?

2) How can I make comparisons between dates and other operations with
the current time. Let's say I want to fire an afternoon_event if the
current time is between 12:00 (a.m.) and 20:00. How to do that? I
could only find the following example:
alarmAbsoluteDatime(ct(X),D2) <- at(X) 'where' (
current_datime(D1), datime_plus_sec(D1,3,D2) ).

But it would be nice to know if it's possible to compare dates or give
a precise time for an event.

hayri

Paul Fodor

unread,
Aug 12, 2010, 10:58:45 AM8/12/10
to eta...@googlegroups.com
Hi Hayri,
Yes, you can compare date-times, add periods of time, etc.
We tried to support multiple Prolog interpreters, so, these methods
are implemented differently for various Prologs. Even running on
Windows or Linux makes a difference (the same datime/1 method in Yap
doesn't work in Windows).
Please look in the src/date_time.P
or online:
http://code.google.com/p/etalis/source/browse/etalis/src/date_time.P

1) Please check your time zone on the computer that you are running
your tests on. The methods are straight forward, so I can only assume
that it takes the Greenwich Time.

2) Please try something like this:
current_datime(datime(Y,M,D,H,Min,Sec)),
less_datime(datime(Y,M,D,H,Min,Sec,0),
datime(T2_Y,T2_M,T2_D,T2_H,T2_Min,T2_S,T2_Counter))

The reason why we added that counter at datime was that a sequence of
events are encountered during a second and the order they came in is
important for CEP.

Regards,
Paul.

Paul Fodor

unread,
Aug 12, 2010, 12:13:20 PM8/12/10
to eta...@googlegroups.com
Hi Hayri,
I modified that predicate, so you don't need to add the counter if you
just want to compare datime structures.
Please update the source code from the SVN repository.
Regards,
Paul.

hayri

unread,
Aug 12, 2010, 12:16:32 PM8/12/10
to ETALIS
Thanks Paul, it really worked with less_datime

I also checked my time zone. It's GMT+1, but Etalis shows 2 hours
difference. I don't get it but it's no big deal now.

I took a look at date_time.P file. There are really some helpful
methods but I would like to implement my own methods too. For instance
I could invert the "less_datime" method and name it "more_datime" or
something like that. I could then define another "between_datime"
method and so on.
The question is, is it allowed to do that. If yes, is it enough to
implement the method in that file or do I need to declare it somewhere
else too?

PF

unread,
Aug 12, 2010, 11:38:38 PM8/12/10
to eta...@googlegroups.com

Yes, great. Please modify that file. We can add you as a developer to
the project.
Regards,
Paul.

Reply all
Reply to author
Forward
0 new messages