SECONDS-FROM-FORMATTED-TIME returns the wrong number of seconds for a time of one second or more with fractional seconds when an earlier intrinsic function in the run left a scale in the work decimal d1 that libcob's intrinsic functions share.
sftfrac.cob (attached) makes four calls with extended time formats, the last one repeating the first:
IDENTIFICATION DIVISION.
PROGRAM-ID. SFTFRAC.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM PIC 9(5)V9(9) VALUE 0.
PROCEDURE DIVISION.
COMPUTE WS-NUM = FUNCTION SECONDS-FROM-FORMATTED-TIME
("hh:mm:ss.s" "00:00:01.5")
DISPLAY "F1 " WS-NUM
COMPUTE WS-NUM = FUNCTION SECONDS-FROM-FORMATTED-TIME
("hh:mm:ss.ss" "00:00:01.50")
DISPLAY "F2 " WS-NUM
COMPUTE WS-NUM = FUNCTION SECONDS-FROM-FORMATTED-TIME
("hh:mm:ss.ssssss" "23:59:59.999999")
DISPLAY "F6 " WS-NUM
COMPUTE WS-NUM = FUNCTION SECONDS-FROM-FORMATTED-TIME
("hh:mm:ss.s" "00:00:01.5")
DISPLAY "F1 " WS-NUM
STOP RUN.
cobc -std=cobol2014 -x sftfrac.cob && ./sftfrac
3.2.0 and 3.3-dev r5751 both print the following, and only the first line is right:
F1 00001.500000000
F2 00000.600000000
F6 08640.899999000
F1 00000.500001000
sftother.cob, attached, shows the same after FUNCTION ABS (-1.25) and after FUNCTION NUMVAL ("1.5"): 10:14:27.8124 comes back as 369.4824 and 3687.5124 instead of 36867.8124.
Every call returns its own time in seconds, whatever ran before it: 1.5, 1.5, 86399.999999 and 1.5. ISO/IEC 1989:2023 15.79.4 rule 1 gives the equivalent arithmetic expression "((H * 3600) + (M * 60) + S)", and 15.3.3.2 makes the fraction part of the seconds subfield S; the same in the 2014 FCD (15.74.3 rule 1).
In libcob/intrinsic.c, seconds_from_formatted_time sets the value of d1 to the whole seconds but not its scale, then adds the fraction with cob_decimal_add: after a scale of 1, the 1 second of "00:00:01.50" counts as 0.1, and 0.1 + 0.50 gives 0.6. The branch for a format without fractional seconds sets the scale to 0, which is why those formats are always right.
The attached n10-seconds-from-formatted-time-scale.patch (against 3.3-dev r5751) inserts seconds_decimal->scale = 0; before the fraction is added, as the other branch already does, and adds a testsuite case, "FUNCTION SECONDS-FROM-FORMATTED-TIME repeated with fractions", to run_functions.at, with ChangeLog entries. With it both programs print the expected values. make check: 1373 expected, 9 skipped, 0 failed; the new test fails without the patch.
bugs #1294: the decimal separator in basic time formats with fractional seconds (hhmmss.sss), a different defect whose patch also changes seconds_from_formatted_time; the two patches apply together in either order.
GnuCOBOL 3.2.0 (Ubuntu gnucobol3 3.2-4build1) and 3.3-dev r5751 (CI snapshot 3.3-dev.138 of 2026-10-29), x86_64 Linux, both programs run on both on 2026-11-04.