Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a more elaborate (overboard?) change than #764. The changes are summarised as:
ConvertTo[..](string str, TimeStampPrecision precision)
methods.DateOnly
andTimeOnly
types for potential future use byDateOnlyField
,TimeOnlyField
etc.API changes:
Some now unused public constants and fields are also removed.
Behavioural changes:
(1) and (2) above together allow offset parsing at any precision of fractional seconds: currently the offset is only parsed in the
ConvertFromNanoString
method which is only reached for long enough input string length (>24):quickfixn/QuickFIXn/Fields/Converters/DateTimeConverter.cs
Lines 115 to 122 in c4e8171
Additionally,
DateTime
value from a string without offset information and up to microsecond precision hasDateTime.Kind
equal toDateTimeKind.Utc
. In this PR it equalsDateTimeKind.Unspecified
.DateTime
value from a string without offset information and more than microsecond precision hasDateTime.Kind
equal toDateTimeKind.Local
. In this PR it equalsDateTimeKind.Unspecified
.DateTime
value from a string with a negative UTC offset is adjusted to the UTC value but hasDateTime.Kind
equal toDateTimeKind.Unspecified
. In this PR it equalsDateTimeKind.Utc
.DateTime
value from a string with a positive UTC offset is adjusted in the wrong direction. In this PR the value is adjusted to the UTC value withDateTime.Kind
equal toDateTimeKind.Utc
. (Fix positive UTC offset parsing in DateTimeConverter #764 is a targeted fix for this)The behaviour of the two methods with
out
parameters is hopefully clear (and agreeable) from the documentation and the tests (which achieve 100% coverage). Here are examples. Note the difference between the two in thatConvertToTimeOnly
does not adjust the return value by the offset (becauseTimeOnly
does not have an equivalent toDateTimeKind
)ConvertToDateTime
new DateTime(2023, 03, 25, 14, 00, 00, DateTimeKind.Unspecified)
and thedateTimeOffset
parameter isnull
new DateTime(2023, 03, 25, 19, 00, 00, DateTimeKind.Utc)
and thedateTimeOffset
parameter is equal tonew DateTimeOffset(2023, 03, 25, 14, 00, 00, TimeSpan.FromHours(-5))
ConvertToTimeOnly
new TimeOnly(14, 00, 00)
and theoffset
parameter isnull
new TimeOnly(14, 00, 00)
and theoffset
parameter is equal toTimeSpan.FromHours(-5)
Where before the conversion could lose information pertaining to the offset, now no information is lost. Perhaps in the future
DateTimeField
andTimeOnlyField
could have corresponding offset properties exposing this information.