[Seed7-users] seed7: time - raise RANGE_ERROR
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
From: Thomas M. <tho...@gm...> - 2022-04-02 22:39:46
|
Hi Anders, You wrote: > I get a raise RANGE_ERROR when running the time-function in seed7 program. > As I remember I did not get this error in the previous versions. > Is this something which has been changed with the new version 2022-03-12? > See the attached testprogram. This is the attached test program: ---------- begin test21.sd7 ---------- $ include "seed7_05.s7i"; include "time.s7i"; const proc: main is func local var time: aTime is time.value; var string: aStr is string.value; begin aStr := str(time(NOW)); writeln(aStr); aTime := time(aStr); writeln(str(aTime)); end func; ---------- end test21.sd7 ---------- Running test21.sd7 leads to: C:\seed7\myprg\Test>s7 test21 SEED7 INTERPRETER Version 5.1.621 Copyright (c) 1990-2021 Thomas Mertes 2022-04-02 06:13:20.211221 UTC+2 (DST) *** Uncaught exception RANGE_ERROR raised with {raise RANGE_ERROR } Stack: in time (in varstring: stri) at /c/seed7/lib/time.s7i(360) in main at test21.sd7(11) C:\seed7\myprg\Test> I can confirm that I also get this RANGE_ERROR and this should not happen. The RANGE_ERROR is triggered because the date string ends with " (DST)". DST means daylight saving time. In "2022-04-02 06:13:20.211221 UTC+2 (DST)" the ending UTC+2 (DST) refers to Middle european summer time. The error is: The function time (string) does not check for " (DST)". Instead it raises RANGE_ERROR. With "2022-04-02 06:13:20.211221 UTC+2" it would work correclty. So the summertime introduced this error. The fix is: I changed time (string) to consider the " (DST)". You can find this fix at GitHub ( https://github.com/ThomasMertes/seed7 ). The change in time.s7i is: end if; end if; end if; + if stri = " (DST)" then + aTime.daylightSavingTime := TRUE; + stri := ""; + end if; end if; - aTime.daylightSavingTime := FALSE; if stri <> "" then raise RANGE_ERROR; end if; I hope this helps. Regards Thomas |