Open bpeake-illuscio opened 3 years ago
I've just pushed an update to this followup that tweaks and adds a couple methods so that you can form a few common interfaces between the dcmtime types. For instance, you can now write a helper function like this:
// DCMTime is a common interface for dcmtime.Date, dcmtime.Time, and dcmtime.Datetime.
type DCMTime interface {
GetTime() time.Time
GetPrecision() dcmtime.PrecisionLevel
DCM() string
}
func InspectDICOMTimeVal(value DCMTime) error {
// Do something with this value
return nil
}
The main addition here is adding a GetTime()
and GetPrecision()
method to each of the dcmtime types. I've been writing some code where a single code path could be used with an interface like this, so I decided it was worth adding in. Callers could do this though wrappers on their own, but having it right out of the box is kind of nice, IMO.
I realize that I am kind of bloating this PR, so let me know if you would like me to try and break this up into smaller PRs. Thanks!
Opening this as a draft, but if you like the API, I think it's ready to be a full PR.
This PR adds several helper methods to the Date, Time, and Datetime types. The work I do involves manipulating DICOM dates and times pretty frequently, so I thought it might be nice to add some quality-of-life features to follow up on the groundwork of #171
Since not all values on a given [Type].Time field are valid due to low precision of the source values, I've added methods for the relevant time values that also report their presence.
Each type has also received a general method to easily check whether a value has at least some precision value.
An example using Datetime:
A method has also been added to both the Date and Time types to combine a Date value and a Time value into a single Datetime value:
Both #186 and #188 have been merged into this branch already.