✅ EF with MySQL getting double/triple time values ?!
So i assign task to user and set the assignTime to DateTime.Now so i should be able to get remaining time right?
For some reason when i set TimeToCompleteTask = 1h and i go to user i get 3h to complete task orr 1h 59min?
27 Replies
first point - don't use DateTime, use DateTimeOffset
Task<Task?>
DateTime does not know anything about time zone offsets and could easily lead to errors calculating durations if you aren't solely using UTC times
well yea i created "Task" as a entity then realized it was bad naming tho
everywhere?
everywhere possible, yes
i set task to 1h xd
besides that, have you checked what times are actually being used in calculations?
like what's getting stored in the db, what are the actual time values when you set a breakpoint after the calculations
nope
that wasn't a yes or no question
well not the one you replied to
do that and see if you can find the problem
does this look good or cursed tho
could be worse, but i think your naming is confusing
that looks like a different value than what
TimeToCompleteTask
in your entity should be
why is it a timespan?idk
that's what i tought it should be
timespans represent durations
im 1st time ever dealing with time
you want datetime/datetimeoffset for a point in time
preferably datetimeoffset
but that's not point in time no?
im confused rn
it's like i set timeToCompleteTask = 2h
so the task is visible fro 2h
how does that make sense in the context of
userTaskAssignment.TimeToCompleteTask - DateTime.Now;
?
you should be comparing DateTime.Now with another point in time, not a duration
i think your naming is just confusing, it should be consistent throughout your code
yeah sure i should rename it
but then i add to it the timeToCompleteTask
so it's point in time
when i compare it
okay, so use your debugger and find out what values you're actually comparing
so i set timeToCompleteTask to 1h
and on site im getting 1h 59mins
what time zone are you in?
i found the issue
There should be JUST "Hours/Minutes/Seconds"
Not total
because with total the minutes were setting to 60 at 1h timeToCompleteTask and the hours timer is also 1h so 2h at ttoal xd
that would also do it