Skip to content

Conversation

@saulius-saltenis-Devoteam
Copy link
Contributor

@saulius-saltenis-Devoteam saulius-saltenis-Devoteam commented Mar 28, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

I store UTC timestamps in DB, and pass ISO timestamps for filtering operations.
When ISO timestamp is passed, it's first converted to DateTime with additional local timezone offset. Later, it's Kind is set to UTC. This only changes the Kind property, retaining the previously added timezone ticks.
image
image
image

For this reason, the following request:
image
Turns into this query:
image

This behavior can be easily reproduced with the following sample, when environment has a timezone:

var dateTime = DateTime.Now;
Console.WriteLine(dateTime);

var utcDateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
Console.WriteLine(utcDateTime);

var utcDateTime2 = dateTime.ToUniversalTime();
Console.WriteLine(utcDateTime2);

image

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have made corresponding changes to the documentation
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

@what-the-diff
Copy link

what-the-diff bot commented Mar 28, 2025

PR Summary

  • Improved DateTime Handling
    An update was made in the way the system interacts with dates and times. This was achieved by using a new approach that can adjust dates and times depending on the default setup of the system. This update provides better control when adjusting between local and international (UTC) times, ensuring accurate date and time information.

Copy link
Owner

@alirezanet alirezanet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @saulius-saltenis-Devoteam,
Looks good to me, but it would be nice if you add a couple of unit-tests to validate the old and new behavior

@saulius-saltenis-Devoteam
Copy link
Contributor Author

Will add either later today, or tomorrow

@saulius-saltenis-Devoteam
Copy link
Contributor Author

Added a test for ensuring that the final query filters with same timestamp as passed via input.
Added two more tests below, that showcase the problem with past conversions.

Copy link
Owner

@alirezanet alirezanet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💐👌 Thanks 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants