-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[git] Git history shows incorrect commit date #1754
Comments
Hello, I am new to open source and was wondering if I could claim this issue. |
Absolutely. It's yours. Let me know if you need help. |
Hi, I could use a little help. Any information to point me in the right direction would be appreciated. Any guidance would be great. |
It is a Here is a small snippet depicting the problem: const t = 1512511924;
console.log(new Date(t)); // Sun Jan 18 1970 13:08:31 GMT+0100 (CET)
const d = new Date(t);
d.setUTCSeconds(t);
console.log(d); // Sat Dec 23 2017 11:20:04 GMT+0100 (CET) You need to do something like this: diff --git a/packages/git/src/browser/history/git-history-widget.ts b/packages/git/src/browser/history/git-history-widget.ts
index 64e74f9d..b6c76107 100644
--- a/packages/git/src/browser/history/git-history-widget.ts
+++ b/packages/git/src/browser/history/git-history-widget.ts
@@ -108,9 +108,11 @@ export class GitHistoryWidget extends GitNavigableListWidget<GitHistoryListNode>
for (const commit of changes) {
const fileChangeNodes: GitFileChangeNode[] = [];
const avatarUrl = await this.avartarService.getAvatar(commit.author.email);
+ const authorDate = new Date(commit.author.timestamp);
+ authorDate.setUTCSeconds(commit.author.timestamp);
commits.push({
authorName: commit.author.name,
- authorDate: new Date(commit.author.timestamp),
+ authorDate,
authorEmail: commit.author.email,
authorDateRelative: commit.authorDateRelative,
authorAvatar: avatarUrl, |
And if you are there, perhaps, you could fix the typo in |
Okay, here are the changes I made then:
|
Looks good. FYI, you can shorten the object literal with this: const avatarUrl = await this.avatarService.getAvatar(commit.author.email);
const authorDate = new Date(commit.author.timestamp);
authorDate.setUTCSeconds(commit.author.timestamp);
commits.push({
authorName: commit.author.name,
authorDate, If you would like to contribute, you have to provide your changes with a pull request and sign it. You can find additional details about it here. If you need help, forking, creating a PR or anything; do not hesitate to ask. I am happy to help you with the onboarding. |
Okay, I sent in the PR. Let me know if there is something else I need to do. Also, let me know if you know of anything else or any other projects I could help out with. I would love to help out and learn more if possible! |
@kittaakos Could you elaborate why and how |
We use
AFAIK, one can convert the epoch time to JS date either with
Let's do that; anything would be better than 1970. |
Do you have any updates on this, @svenefftinge or can we update the Git API (changing the epoch number to the desired string) in a separate ticket? If the fix is right, I do the review. Thanks! |
Fixes #1770 Fixes #1754 - Fixes error thrown when attempting to perform `Date.toLocaleDateString` in the `git-commit-detail-widget`. - Fixes error thrown when attempting to iterate over `fileChangeNodes` and it is `undefined`. - Fix typo when no git history is available - Simplify logic in `addCommits` Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Fixes #1770 Fixes #1754 - Fixes error thrown when attempting to perform `Date.toLocaleDateString` in the `git-commit-detail-widget`. - Fixes error thrown when attempting to iterate over `fileChangeNodes` and it is `undefined`. - Fix typo when no git history is available - Simplify logic in `addCommits` - Refactor `epoch` time to instead use `ISO` strings Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Fixes #1770 Fixes #1754 - Fixes error thrown when attempting to perform `Date.toLocaleDateString` in the `git-commit-detail-widget`. - Fixes error thrown when attempting to iterate over `fileChangeNodes` and it is `undefined`. - Simplify logic in `addCommits` - Refactor `epoch` time to instead use `ISO` strings Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Fixes #1770 Fixes #1754 - Fixes error thrown when attempting to perform `Date.toLocaleDateString` in the `git-commit-detail-widget`. - Fixes error thrown when attempting to iterate over `fileChangeNodes` and it is `undefined`. - Simplify logic in `addCommits` - Refactor `epoch` time to instead use `ISO` strings Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Fixes eclipse-theia#1770 Fixes eclipse-theia#1754 - Fixes error thrown when attempting to perform `Date.toLocaleDateString` in the `git-commit-detail-widget`. - Fixes error thrown when attempting to iterate over `fileChangeNodes` and it is `undefined`. - Simplify logic in `addCommits` - Refactor `epoch` time to instead use `ISO` strings Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com> Signed-off-by: Bogdan Stolojan <petre.stolojan@arm.com>
One has to call:
on the date when converting the epoch time to date.
Here: https://github.com/theia-ide/theia/blob/25c91c41a93b9e4f51786f7d9b5fca6a7bd19525/packages/git/src/browser/history/git-history-widget.ts#L113
The text was updated successfully, but these errors were encountered: