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 local time to hover cards based on user location #1233
Comments
The previous attempt became rather large and added a permission to Google's servers, which isn't great. I saw that @SamVerschueren made a CLI tool to get this information: https://github.com/SamVerschueren/dev-time It uses the API to get the latest push but then uses Perhaps its logic can be adjusted to only use the API |
Would be great if the tool didn't had to clone the repository. At the time I made it I couldn't find another way. |
Hello, sorry, any updates on this? |
@fregante I found a way to do this without cloning the repository.
A problems I found with this approach is that This means it is possible but it might include several (at least two) requests. /cc @SamVerschueren if he wants to use this somehow |
Okay so I started to play around with this a bit here It's still WIP, but it already works 😄 I haven't solved the commiter issuer yet! Also I needed a modified Should I open a (Draft?) PR for this already? |
I don't see any way to find out. I tried looking at the requests being made and I can't find a way to programmatically tell if this commit was authored by me: You can click that link to see the API result in the browser, and here's the From 8d556c5d9dc0f5471abddacfe84667dd72b1bb23 Mon Sep 17 00:00:00 2001
From: Jimmy Gaussen <jimmygaussen@gmail.com>
Date: Fri, 8 Nov 2019 02:14:39 +0100
Subject: [PATCH] Allow PR merge-only bots in `dim-bots` (#2519)
---
source/features/dim-bots.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source/features/dim-bots.tsx b/source/features/dim-bots.tsx
index 18298f96c..6cf43b6a6 100644
--- a/source/features/dim-bots.tsx
+++ b/source/features/dim-bots.tsx
@@ -5,8 +5,8 @@ import features from '../libs/features';
function init(): void {
const bots = select.all([
/* Commits */
- '.commit-author[href$="%5Bbot%5D"]',
- '.commit-author[href$="renovate-bot"]',
+ '.commit-author[href$="%5Bbot%5D"]:first-child',
+ '.commit-author[href$="renovate-bot"]:first-child',
/* PRs */
'.opened-by [href*="author%3Aapp%2F"]' Who is Jimmy? Who is @fregante? Are they the same person? Side note: the |
It should be possible to check it the event So a very simple approach would be: const event = await getPushEvent(login);
const lastCommit = event.payload.commits[event.payload.commits.length - 1];
const commit = await fetch(lastCommit.url);
if (commit.author.id === event.actor.id) {
return commit;
}
// Check the next commit or event or load more events...
// This might take a bit but hopefully we are on the happy path 😄 Example
|
I think that's right! To put it plainly, Now, back to the algorithm here. 😅 I think you need this: def getTimezone(user): string
while await fetch eventPage+1
for event in eventPage
if event is pushevent
for commit in event # each event can have multiple commits. maybe this loop can be skipped though
await fetch commit
if commit.author.id === event.actor.id
await fetch patch
return patch.date.timezone |
If you implement this I suggest keeping it in a single function/loop for now, we can optimize it later if needed. It’s easier to just |
Okay I implemented it and it works pretty good. A good place to test would be the contributors page. I already found some interesting edge cases through that 😄 |
@fregante Is 12 hour format available? |
It's not, but PR welcome to replace the <local-time minute="numeric" hour="numeric" datetime={....}/> |
Hey, how will this further help me in setting 24 Hr format in my PC? Btw I did some changes and got same 24 hr format. code is here. |
"CDT timezone" is American and they prefer 12-hour. But I don't think it has anything to do with my timezone as their readme suggests, but just the browser's language. Even Safari ignores my OS' preference to display 24-hour so I'm guessing it's all about that locale string. new Intl.DateTimeFormat(undefined,{hour:"numeric", minute:"numeric"}).format(new Date); What does this output for you? It's 12-hour for me because my locale is I thought that their element was somehow smarter than our code, but the only difference is that our code explicitly asks Related but unsolved: whatwg/html#171 |
I just did |
When collaborating on open-source with people from around the world, it's good to know if the local time with the person you're communicating is in the morning/evening.
The text was updated successfully, but these errors were encountered: