server icon indicating copy to clipboard operation
server copied to clipboard

Error in duration

Open seb49 opened this issue 1 year ago • 3 comments

Hello,

I'm in France, it's 05:25 PM, I have an active timer launch à 1:07 PM so barely 4 hours and 20 minutes. But traggo display only 2 hours and 20 minutes

image

seb49 avatar May 13 '24 15:05 seb49

Could you share your database file. You could send it to the email on my profile. This is likely due to starting and stopping the time span in different timezones, this can be due to different browser settings.

jmattheis avatar May 14 '24 20:05 jmattheis

This is done

seb49 avatar May 15 '24 06:05 seb49

In the same way, there are 2 hours gap in this view image

seb49 avatar May 15 '24 06:05 seb49

Yeah, you likely use traggo from browsers that have different timezones configured. There are offsets for gmt+2, gmt+1 and utc in the database.

Tracking time across time zones is really difficult. In your first screenshat your browser is likely configured in utc time. So at 17:00 in france it's 15:00 utc and the the duration is fine. You can probably fix this by configuring your browser so that it has the correct timezone.

jmattheis avatar May 15 '24 17:05 jmattheis

Thanks for your reply

I think it's more touchy. I use graphql to create entries. But I show in database there is this field

start_utc
end_utc
start_user_time
end_user_time

but graphql use only start and end

createTimeSpan(
start: Time!
end: Time
tags: [InputTimeSpanTag!]
note: String!
): TimeSpan

here is some entries from databases

sqlite> select * from time_spans where id in (377,378,379);
377|2024-05-16 08:11:31+00:00||2024-05-16 08:11:31+00:00||0|1|PYTHON
378|2024-05-16 07:18:56+00:00|2024-05-16 07:20:54+00:00|2024-05-16 09:18:56+00:00|2024-05-16 09:20:54+00:00|7200|1|
379|2024-05-16 07:27:25+00:00||2024-05-16 09:27:25+00:00||7200|1|

if you read "Python", entry is create with graphql, otherwise, from browser. With browser there is 2 hours gap between user_time and utc

Regards

seb49 avatar May 16 '24 07:05 seb49

Then you have to fix this in your script and send your timestamps with a timezone offset.

jmattheis avatar May 17 '24 19:05 jmattheis

This is what I do to get time def GetCurrentDate(): current_datetime_utc = datetime.now(timezone.utc).replace(tzinfo=pytz.UTC) desired_timezone = pytz.timezone('Europe/Paris') current_datetime_Paris = current_datetime_utc.astimezone(desired_timezone) formatted_datetime_utc_plus_one = current_datetime_Paris.strftime("%Y-%m-%dT%H:%M:%SZ") return formatted_datetime_utc_plus_one

But event if I remove desired_timezone = pytz.timezone('Europe/Paris')

there is no logic

image

image

the good display is on the calendar

seb49 avatar May 21 '24 07:05 seb49

Not a python dev, but you can get the current time with a timezone which will return the right offset.

def GetCurrentDate():
    tz = pytz.timezone('Europe/Paris')
    return datetime.now(tz).isoformat()
# outputs: 2024-05-21T12:06:08.996211+02:00

Your method outputs 2024-05-21T12:06:08Z

jmattheis avatar May 21 '24 10:05 jmattheis

Great, it's work thanks. But I don't understand why the table contains more filed than graphql can use (start_utc, end_utc, start_user_time, end_user_time)

seb49 avatar May 22 '24 06:05 seb49