Date string to UNIX time in SWI Prolog?

From: Michael David Pedersen (mdp_at_cs.auc.dk)
Date: 05/24/04


Date: Mon, 24 May 2004 16:43:23 +0200

Hi all,

I am in desperate need of a way to translate a ISO 8601 date string in the
format 'YYYYMMDD' to the corresponding UNIX time stamp (i.e. seconds since
January 1st 1970.

The only relevant predicates which SWI seems to offer are:

convert_time(+Time, -Year, -Month, -Day, -Hour, -Minute, -Second, -MilliSeco
nds) and
convert_time(+Time, -String)

But these only allow converting from a unix time to some other
representation! I need to go the other way around, and I would like to avoid
writing this code my self (taking leap years into accound etc.). What to do?

One (unclean) solution is to use shell(+Command, -Status) to call an
external shell command which handles the conversion. If this is the best way
out, how would I go about receiving a return value?

Hope that someone has an answer -- any help will be greatly appreciated.

Regards,
Michael.



Relevant Pages

  • Re: Possible date conversion bug in Regina
    ... Lee Peedin wrote: ... I tried adding 3601 to the Unix time, ... converting back gives me the same date. ... Looking for a good MVS systems programmer position ...
    (comp.lang.rexx)
  • Convert UNIX time to windows general date
    ... I'm importing a table from a MYSQL database that contains a UNIX time stamp ... data field. ...
    (microsoft.public.access.queries)
  • Re: [PHP] convert unix time to Gregorian
    ... I successfully convert unix time to Gregorian. ... But Gregorian time is now showing hour and second and more detail time. ... If some knows convert Unix time stamp to Gregorian with hour and second, ...
    (php.general)
  • convert unix time to Gregorian
    ... I successfully convert unix time to Gregorian. ... But Gregorian time is now showing hour and second and more detail time. ... If some knows convert Unix time stamp to Gregorian with hour and second, ...
    (php.general)