fifth-postulate / julian

Date and time library for Prolog
The Unlicense
27 stars 3 forks source link

error on load #9

Open Anniepoo opened 9 years ago

Anniepoo commented 9 years ago

ERROR: c:/program files/swipl/pack/julian/prolog/julian.pl:29: Wrong context: type/1 can only be used in a directive Warning: c:/program files/swipl/pack/julian/prolog/julian.pl:29: Goal (directive) failed: julian:type(--->(duration, (days(integer);s(integer);ms(integer);ns(integer))))

mndrix commented 9 years ago

It looks like you need to install the typedef pack. Does that resolve the problem?

Anniepoo commented 9 years ago

no, I had typedef installed , reinstalling does not help

mndrix commented 9 years ago

I'm unable to reproduce the problem locally. Can you provide a minimal file that exhibits the problem for you? I tried use_module(library(julian)) and variations.

It looks like something is preventing term_expansion from executing for the typedef package. That leaves type/1 to execute as a goal which throws the exception you see.

chiahli commented 8 years ago

Hi, i am too experiencing the same error message.

?- use_module(library(julian)). ERROR: /Applications/SWI-Prolog.app/Contents/swipl/pack/julian/prolog/julian.pl:29: Wrong context: type/1 can only be used in a directive Warning: /Applications/SWI-Prolog.app/Contents/swipl/pack/julian/prolog/julian.pl:29: Goal (directive) failed: julian:type(--->(duration, (days(integer);s(integer);ms(integer);ns(integer)))) true.

I wonder if this is an issue that caused the following example from your tutorial on RFC3339 not working properly?

?- form_time(now, _T), | form_time(rfc3339(RFC), _T). _T = datetime(57391, 13058276446208), RFC = [50, 48, 49, 54, 45, 48, 49, 45, 48|...].

mndrix commented 8 years ago

i am too experiencing the same error message

I'm still not able to reproduce this problem locally. Which version of SWI-Prolog are you using? What output do you get when you run the following command:

swipl -f none -g 'use_module(library(julian)), writeln(ok).' -t halt
chiahli commented 8 years ago

version 7.2.3 for mac.

Here's the output. ?- swipl -f none -g 'use_module(library(julian)), writeln(ok).' -t halt. ERROR: Syntax error: Operator expected ERROR: swipl -f ERROR: \ here ** ERROR: none -g 'use_module(library(julian)), writeln(ok).' -t halt .

Managed to get around the issue by assuming it could be a string thing: ?- form_time(now, _T), form_time(rfc3339(RFC), _T), string_codes(String, RFC). _T = datetime(57390, 61834954753024), RFC = [50, 48, 49, 54, 45, 48, 49, 45, 48|...], String = "2016-01-03T17:10:34.954753".