logo       

weird behavior of timestamp in convert_time: msg#01580

Subject: weird behavior of timestamp in convert_time
Hello,
 while working on time and date in a small program fragment in the 
Version 5.5.38 of swi-prolog i have come across a bahavior a could not 
understand. Maybe it is a bug maybe not since it has to do with daylight 
savings.

here is the code fragment

isodate(ISO,TMSTP) :-
        var(TMSTP),nonvar(ISO),!,
        concat_atom([ISOD,ISOT],'T',ISO),
        concat_atom([Ye,Mo,Da],'-',ISOD),
        concat_atom([Ho,Mi,Se],':',ISOT),
        new(X,date(Se,Mi,Ho,Da,Mo,Ye)),
        get(X, posix_value, TMSTP).


isodate(ISO,TMSTP) :-
        nonvar(TMSTP),var(ISO),!,
        convert_time(TMSTP, Ye, Mo, Da, Ho,Mi,Se, _),
        concat_atom([Ye,Mo,Da],'-',ISOD),
        concat_atom([Ho,Mi,Se],':',ISOT),
        concat_atom([ISOD,ISOT],'T',ISO).


now if you test it with

:- isodate('2005-03-22T10:20:05',X),isodate(Z,X).
X = 1.11148e+09
Z = '2005-3-22T10:20:5' ;


everything work fine.

but if you use a month in wich daylight savings apply (like april == 04)

:- isodate('2005-04-22T10:20:05',X),isodate(Z,X).
X = 1.11416e+09
Z = '2005-4-22T11:20:5' ;

as you can see the time shifts forward by an hour.

what i cant understand id why since this must must be a mirror transformation
going back and forth the same date and time it must not change even in 
daylight savings ?

any help will be appreciated.

Mauro



-- 

mauro@xxxxxxxxxxx
http://www.preciso.net

-----------------------------------
"J'ai vu, pendant toute ma vie, sans en excepter 
un seul, les hommes, aux �paules �troites, faire 
des actes stupides et nombreux, abrutir leurs 
semblables, et pervertir les �mes par tous les 
moyens. Ils appellent les motifs de leurs actions: la gloire. 
En voyant ces spectacles, j'ai voulu rire comme les autres; 
mais cela, �trange imitation, �tait impossible. 
J'ai pris un canif dont la lame avait un tranchant 
ac�r�, et me suis fendu les chairs aux endroits o� 
se r�unissent les l�vres......"

tratto da: "Les Chants de Maldoror". Comte de Lautr�amont (1846-1870) 
        http://un2sg4.unige.ch/athena/lautreamont/laut_mal.html
-----------------------------------



<Prev in Thread] Current Thread [Next in Thread>