Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joewatt95 committed Oct 11, 2023
1 parent a0c8746 commit b8dde05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
22 changes: 21 additions & 1 deletion declarative_date_time/declarative_date_time.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
:- module(declarative_date_time, [
valid_date/1, % valid_date_smt/1,
to_date/2,
is_duration_before/3
is_duration_before/3,
between_dates/3,
is_duration_before_after_within/4
]).

:- use_module(library(clpfd)).
Expand All @@ -11,6 +13,24 @@
% :- py_add_lib_dir(declarative_date_time).
% :- py_add_lib_dir(.).

is_duration_before_after_within(Date0, Duration, before, Date1) :-
is_duration_before(Date0, Duration, Date1).

is_duration_before_after_within(Date0, Duration, after, Date1) :-
is_duration_before(Date1, Duration, Date0).

is_duration_before_after_within(Date0, Duration, within, Date1) :-
is_duration_before(Date0, Duration, Date),
between_dates(Date0, Date1, Date), !.

is_duration_before_after_within(Date0, Duration, within, Date1) :-
is_duration_before(Date, Duration, Date0),
between_dates(Date, Date1, Date0), !.

between_dates(Date0, Date, Date1) :-
is_duration_before(Date0, days(_), Date),
is_duration_before(Date, days(_), Date1), !.

valid_year(Year) :- Year in 1900..2200.

is_duration_before(Date, Duration, Date) :-
Expand Down
19 changes: 1 addition & 18 deletions reasoner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
run_examples/0, run_examples/1, myClause2/9, myClause/4, taxlogWrapper/10, niceModule/2, refToOrigin/2,
isafter/2, is_not_before/2, isbefore/2, immediately_before/2, same_date/2, subtract_days/3, this_year/1, uk_tax_year/4, in/2,
isExpressionFunctor/1, set_time_of_day/3, start_of_day/2, end_of_day/2, is_days_after/3, is_1_day_after/2, unparse_time/2, product_list/2,
valid_date/1, to_date/2, is_duration_before_after_within/4
valid_date/1, to_date/2, between_dates/3, is_duration_before_after_within/4
% is_duration_before_dates/3
]).

Expand Down Expand Up @@ -726,23 +726,6 @@
format_time(string(Start),"%F",date(StartYear,4,6)),
format_time(string(End),"%F",date(EndYear,4,5)).

is_duration_before_after_within(Date0, Duration, before, Date1) :-
is_duration_before(Date0, Duration, Date1).

is_duration_before_after_within(Date0, Duration, after, Date1) :-
is_duration_before(Date1, Duration, Date0).

is_duration_before_after_within(Date0, Duration, within, Date1) :-
is_duration_before(Date0, Duration, Date),
between_dates(Date0, Date1, Date).

is_duration_before_after_within(Date0, Duration, within, Date1) :-
is_duration_before(Date, Duration, Date0),
between_dates(Date, Date1, Date0).

between_dates(Date0, Date, Date1) :-
is_duration_before(Date0, _, Date), is_duration_before(Date, _, Date1).

%! in(X,List) is nondet.
% X is in List
in(X,List) :- must_be(list,List), member(X,List).
Expand Down

0 comments on commit b8dde05

Please sign in to comment.