Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.

Commit 2b9bcdf

Browse files
committed
fix: Use unix seconds to record update time
1 parent 6d76f13 commit 2b9bcdf

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

shadowsocks-csharp/Controller/MenuViewController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ private void UpdateNodeCheckerNewNodeFound(object sender, EventArgs e)
542542
{
543543
foreach (var serverSubscribe in config.ServerSubscribes.Where(serverSubscribe => serverSubscribe.Url == Global.UpdateNodeChecker.SubscribeTask.Url))
544544
{
545-
serverSubscribe.LastUpdateTime = (ulong)DateTimeOffset.Now.ToUnixTimeSeconds();
545+
serverSubscribe.LastUpdateTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
546546
}
547547

548548
var defaultServer = new Server();

shadowsocks-csharp/Model/ServerSubscribe.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ServerSubscribe : ViewModelBase
1313
{
1414
private string _url;
1515
private string _tag;
16-
private ulong _lastUpdateTime;
16+
private long _lastUpdateTime;
1717
private bool _autoCheckUpdate;
1818
private HttpRequestProxyType _proxyType;
1919

@@ -58,7 +58,7 @@ public string Tag
5858
}
5959
}
6060

61-
public ulong LastUpdateTime
61+
public long LastUpdateTime
6262
{
6363
get => _lastUpdateTime;
6464
set

shadowsocks-csharp/View/SubscribeWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Window x:Class="Shadowsocks.View.SubscribeWindow"
1+
<Window x:Class="Shadowsocks.View.SubscribeWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:model="clr-namespace:Shadowsocks.Model"
@@ -36,7 +36,7 @@
3636
</DockPanel>
3737
</StackPanel>
3838
</DataTemplate>
39-
<valueConverter:UlongToDateTimeString x:Key="UlongToDateTimeString" />
39+
<valueConverter:UnixSecondsToString x:Key="UlongToDateTimeString" />
4040
<valueConverter:ProxyTypeConverter x:Key="ProxyTypeConverter" />
4141
</ResourceDictionary>
4242
</Window.Resources>

shadowsocks-csharp/View/ValueConverter/UlongToDateTimeString.cs renamed to shadowsocks-csharp/View/ValueConverter/UnixSecondsToString.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33

44
namespace Shadowsocks.View.ValueConverter
55
{
6-
public class UlongToDateTimeString : IValueConverter
6+
public class UnixSecondsToString : IValueConverter
77
{
88
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
99
{
10-
if (value is ulong lastUpdateTime && targetType == typeof(string))
10+
if (value is long lastUpdateTime && targetType == typeof(string))
1111
{
12-
if (lastUpdateTime != 0)
12+
if (lastUpdateTime is not 0)
1313
{
14-
var now = new DateTime(1970, 1, 1, 0, 0, 0);
15-
now = now.AddSeconds(lastUpdateTime);
16-
return $@"{now.ToLongDateString()} {now.ToLongTimeString()}";
14+
return DateTimeOffset.FromUnixTimeSeconds(lastUpdateTime).ToLocalTime().ToString();
1715
}
1816
}
1917
return @"(`・ω・´)";

0 commit comments

Comments
 (0)