Skip to content

Commit 08ea12c

Browse files
committedFeb 8, 2025
Truncate seconds to 59 (#912)
1 parent 7f3cbc9 commit 08ea12c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎console/nii_dicom_batch.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -3858,7 +3858,17 @@ int nii_createFilename(struct TDICOMdata dcm, char *niiFilename, struct TDCMopts
38583858
isSeriesReported = true;
38593859
}
38603860
if (f == 'T') {
3861-
snprintf(newstr, PATH_MAX, "%0.0f", dcm.dateTime);
3861+
//issue912
3862+
int hh = (int)(dcm.dateTime / 10000);
3863+
int mm = (int)(fmod(dcm.dateTime, 10000) / 100);
3864+
double ss_raw = fmod(dcm.dateTime, 100); // Extract seconds (with fraction)
3865+
// Round seconds
3866+
int ss = (int)round(ss_raw);
3867+
// Ensure seconds are within 0-59 range
3868+
if (ss == 60) {
3869+
ss = 59;
3870+
}
3871+
snprintf(newstr, PATH_MAX, "%02d%02d%02d", hh, mm, ss);
38623872
strcat(outname, newstr);
38633873
}
38643874
if (f == 'U') {

0 commit comments

Comments
 (0)
Failed to load comments.