rexcardan / Evil-DICOM

A C# DICOM Library
171 stars 98 forks source link

Trailing zero are removed at writing #23

Closed Ritterbrater closed 9 years ago

Ritterbrater commented 9 years ago

Hi!

Nice library and also nice documentation on your website!

Problem: time stamps with trailing zeros will be truncated on writing. To give an example: (0018,1201) TM [from file 1] [075937.000000 ] # Time of Last Calibration (this is the original file) (0018,1201) TM [from file 2] [075937] # Time of Last Calibration (this is the file written by Evil DICOM)

The original file is from a clinical CT system. I don't know if this problem can happen with doubles, too.

rexcardan commented 9 years ago

This is happening in the DataComposer class:

    public static string ComposeTime(DateTime? data)
    {
        if (data != null)
        {
            var date = (DateTime) data;
            if (data.Value.Millisecond > 0)
            {
                return date.ToString("HHmmss.ffffff");
            }
            return date.ToString("HHmmss");
        }
        return string.Empty;
    }

If will simplify to:

    public static string ComposeTime(DateTime? data)
    {
        if (data != null)
        {
            var date = (DateTime) data;
            return date.ToString("HHmmss.ffffff");
        }
        return string.Empty;
    }

I'm not sure what I was thinking on that.