3 ms·
To reason about dates and times in a purely declarative way with Prolog, the best way I have seen is library(julian) by Michael Hendricks: http://mndrix.github
by zmonx 9y ago
To reason about dates and times in a purely declarative way with Prolog, the best way I have seen is library(julian) by Michael Hendricks:
http://mndrix.github.io/julian/ http://mndrix.github.io/julian/
For example:
?- form_time([2014-5-1], T).
T = datetime(56778, _5804),
_5804 in 0..86399999999999.
This uses CLP(FD) constraints to reason about time in a very general way, usable in all direction. For example, you can express "all times after 2014-5-1" as follows:
?- form_time([after(2014-5-1)], T).
T = datetime(_1304, _1306),
_1304 in 56778..514671,
_1346#=86400000000000*_1304+_1306,
_1346 in 4905619200000000001..44467660799999999999,
_1416#=<_1346+ -1,
_1416 in 4905619200000000000..4905705599999999999,
4905619200000000000+_1484#=_1416,
_1484 in 0..86399999999999,
_1306 in 0..86399999999999.