question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignoring DateTime.Kind?

See original GitHub issue

In 4.76.0, how would I go about configuring CompareLogic to ignore the Kind property of DateTime objects? IgnoreDateTimeOffsetTimezones = true does not work it seems.

Diff string looks like this:

Types [DateTime,DateTime], Item Expected.StartDate != Actual.StartDate, Values (2022-03-28 13:46:00,2022-03-28 13:46:00)

The only differences between the objects is Kind.Utc vs Kind.Unspecified.

expected actual

I think the Unspecified kind is due to a bug/feature in .Net Core 3 APIs. It only happens when I call the API with Postman using a body containing:

"StartDate": "{{dateTimeNow}}"

… where dateTimeNow is specified in the following way in the pre-request script:

var dateTimeNow = pm.variables.replaceIn("{{$isoTimestamp}}");

I also think the common solution to this problem is to force Kind.Utc onto DateTime objects created from the incoming request body, and I could potentially do that, but I’m not sure at this point what it would do on the API consumer side.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
GregFinzercommented, Apr 25, 2022
0reactions
ltrzesniewskicommented, Apr 25, 2022

Thanks! 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - DateTime Compare Ignores Kind?
It's not exactly a bug but a shortcoming of DateTime . The DateTime type doesn't support timezone information apart from a local/UTC indicator....
Read more >
DateTime.SpecifyKind(DateTime, DateTimeKind) Method
Creates a new DateTime object that has the same number of ticks as the specified DateTime, but is designated as either local time,...
Read more >
Allow specifying a default DateTimeKind #12994
Am I ignoring missing use cases that would break such a default, or would implementing this separately from default value converters be too ......
Read more >
DateTimePicker Advice - Explicitly specify Kind - PI Square
DateTimePicker Advice - Explicitly specify Kind ... A: If a control is not documented, the best option is to ignore it.
Read more >
DateTime is retrieved with DateTimeKind.Unspecified even ...
I am on version 4.0 Final using adapter. My issue is explained her: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=17566.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found