mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix: try to fix the timezone issue (#229)
This commit is contained in:
parent
4ef0f1180f
commit
57a2144777
4 changed files with 8 additions and 14 deletions
|
@ -9,7 +9,6 @@ namespace SourceGit.Commands
|
||||||
|
|
||||||
[GeneratedRegex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)")]
|
[GeneratedRegex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)")]
|
||||||
private static partial Regex REG_FORMAT();
|
private static partial Regex REG_FORMAT();
|
||||||
private static readonly DateTime UTC_START = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
|
|
||||||
|
|
||||||
public Blame(string repo, string file, string revision)
|
public Blame(string repo, string file, string revision)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +66,7 @@ namespace SourceGit.Commands
|
||||||
var commit = match.Groups[1].Value;
|
var commit = match.Groups[1].Value;
|
||||||
var author = match.Groups[2].Value;
|
var author = match.Groups[2].Value;
|
||||||
var timestamp = int.Parse(match.Groups[3].Value);
|
var timestamp = int.Parse(match.Groups[3].Value);
|
||||||
var when = UTC_START.AddSeconds(timestamp).ToString("yyyy/MM/dd");
|
var when = DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime().ToString("yyyy/MM/dd");
|
||||||
|
|
||||||
var info = new Models.BlameLineInfo()
|
var info = new Models.BlameLineInfo()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,14 +19,13 @@ namespace SourceGit.Models
|
||||||
public bool IsMerged { get; set; } = false;
|
public bool IsMerged { get; set; } = false;
|
||||||
public Thickness Margin { get; set; } = new Thickness(0);
|
public Thickness Margin { get; set; } = new Thickness(0);
|
||||||
|
|
||||||
public string AuthorTimeStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd HH:mm:ss");
|
|
||||||
public string CommitterTimeStr => _utcStart.AddSeconds(CommitterTime).ToString("yyyy/MM/dd HH:mm:ss");
|
public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
public string AuthorTimeShortStr => _utcStart.AddSeconds(AuthorTime).ToString("yyyy/MM/dd");
|
public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
public string CommitterTimeShortStr => _utcStart.AddSeconds(CommitterTime).ToString("yyyy/MM/dd");
|
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd");
|
||||||
|
public string CommitterTimeShortStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToString("yyyy/MM/dd");
|
||||||
|
|
||||||
public bool IsCommitterVisible => Author != Committer || AuthorTime != CommitterTime;
|
public bool IsCommitterVisible => Author != Committer || AuthorTime != CommitterTime;
|
||||||
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
||||||
|
|
||||||
private static readonly DateTime _utcStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,11 @@ namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
public class Stash
|
public class Stash
|
||||||
{
|
{
|
||||||
private static readonly DateTime UTC_START = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).ToLocalTime();
|
|
||||||
|
|
||||||
public string Name { get; set; } = "";
|
public string Name { get; set; } = "";
|
||||||
public string SHA { get; set; } = "";
|
public string SHA { get; set; } = "";
|
||||||
public ulong Time { get; set; } = 0;
|
public ulong Time { get; set; } = 0;
|
||||||
public string Message { get; set; } = "";
|
public string Message { get; set; } = "";
|
||||||
|
|
||||||
public string TimeStr => UTC_START.AddSeconds(Time).ToString("yyyy/MM/dd HH:mm:ss");
|
public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public Statistics()
|
public Statistics()
|
||||||
{
|
{
|
||||||
_utcStart = DateTime.UnixEpoch;
|
|
||||||
_today = DateTime.Today;
|
_today = DateTime.Today;
|
||||||
_thisWeekStart = _today.AddSeconds(-(int)_today.DayOfWeek * 3600 * 24 - _today.Hour * 3600 - _today.Minute * 60 - _today.Second);
|
_thisWeekStart = _today.AddSeconds(-(int)_today.DayOfWeek * 3600 * 24 - _today.Hour * 3600 - _today.Minute * 60 - _today.Second);
|
||||||
_thisWeekEnd = _thisWeekStart.AddDays(7);
|
_thisWeekEnd = _thisWeekStart.AddDays(7);
|
||||||
|
@ -115,7 +114,7 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public void AddCommit(string committer, double timestamp)
|
public void AddCommit(string committer, double timestamp)
|
||||||
{
|
{
|
||||||
var time = _utcStart.AddSeconds(timestamp).ToLocalTime();
|
var time = DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime();
|
||||||
if (time.CompareTo(_thisWeekStart) >= 0 && time.CompareTo(_thisWeekEnd) < 0)
|
if (time.CompareTo(_thisWeekStart) >= 0 && time.CompareTo(_thisWeekEnd) < 0)
|
||||||
{
|
{
|
||||||
Week.AddCommit((int)time.DayOfWeek, committer);
|
Week.AddCommit((int)time.DayOfWeek, committer);
|
||||||
|
@ -136,7 +135,6 @@ namespace SourceGit.Models
|
||||||
Week.Complete();
|
Week.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DateTime _utcStart;
|
|
||||||
private readonly DateTime _today;
|
private readonly DateTime _today;
|
||||||
private readonly DateTime _thisWeekStart;
|
private readonly DateTime _thisWeekStart;
|
||||||
private readonly DateTime _thisWeekEnd;
|
private readonly DateTime _thisWeekEnd;
|
||||||
|
|
Loading…
Reference in a new issue