Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add timezone to title in span element #175

Merged
merged 1 commit into from
Mar 14, 2025

Conversation

mschoettle
Copy link
Contributor

Follow-up to #152 where we discussed to add the timezone.

There is a weird behaviour with the timezone. It does not seem to respect the timezone the process is run in.

For example:

$ date
Fri Mar 14 09:51:36 EDT 2025
$ uv run mkdocs serve

Still shows UTC.

Maybe it is intended due to the timezone config setting. However, I wonder if it would not be better to call astimezone() instead to get the current timezone.

@mschoettle mschoettle changed the title add timezone to title in span add timezone to title in span element Mar 14, 2025
@mschoettle mschoettle force-pushed the span-title-timezone branch from 1ab95aa to ff6811d Compare March 14, 2025 14:02
@timvink
Copy link
Owner

timvink commented Mar 14, 2025

There is a weird behaviour with the timezone. It does not seem to respect the timezone the process is run in.

That's a feature, not a bug :) git dates are stored as unix timestamps, which is the number of seconds since the Unix Epoch on January 1st, 1970 at UTC.

commit_timestamp = git.log(
realpath,
date="unix",
format="%at",
diff_filter="r",
n=1,
no_show_signature=True,
follow=follow_option,
ignore_all_space=True,
ignore_blank_lines=True,
)

So the system date is irrelevant.

@timvink timvink merged commit 0c28fec into timvink:master Mar 14, 2025
15 checks passed
@timvink
Copy link
Owner

timvink commented Mar 14, 2025

Thanks, nice addition!

@mschoettle
Copy link
Contributor Author

Thanks for the quick response!

What I meant is that it would be nice to be able to convert the datetime from the log (which is in UTC) to the local timezone automatically instead of having to explicitly set the timezone config. Maybe not by default though. That way it could automatically match the system timezone.

@mschoettle mschoettle deleted the span-title-timezone branch March 14, 2025 16:00
@timvink
Copy link
Owner

timvink commented Mar 14, 2025

Yes that would be nice. Probably #156 would help, but it won't display the UTC time in the local time.

There are probably lots of js libraries that can convert UTC to browser timestamps, but I'm not sure this plugin should support it.

@mschoettle
Copy link
Contributor Author

@timvink I realized that I forgot to update the documentation about the new date format option as well as the fact that if it is used that the timezone should most likely be set. Shall I open another PR to update it?

There are probably lots of js libraries that can convert UTC to browser timestamps, but I'm not sure this plugin should support it.

Indeed. That would be best. The documentation talks about doing a conversion between client and server timezone for timeago. I assume that is in this plugin itself. Couldn't something like this be used here as well?

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