浏览代码

Use Humanizer for Countdown mode

No longer uses the regular formatting which didn't work all the time.
Daniel Chalmers 3 年之前
父节点
当前提交
049f343395
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 1 0
      DesktopClock/DesktopClock.csproj
  2. 2 1
      DesktopClock/MainViewModel.cs

+ 1 - 0
DesktopClock/DesktopClock.csproj

@@ -17,6 +17,7 @@
 
   <ItemGroup>
     <PackageReference Include="Costura.Fody" Version="4.1.0" PrivateAssets="All" />
+    <PackageReference Include="Humanizer.Core" Version="2.14.1" />
     <PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
     <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
     <PackageReference Include="PropertyChanged.Fody" Version="3.3.1" PrivateAssets="All" />

+ 2 - 1
DesktopClock/MainViewModel.cs

@@ -4,6 +4,7 @@ using System.Windows.Input;
 using DesktopClock.Properties;
 using GalaSoft.MvvmLight;
 using GalaSoft.MvvmLight.CommandWpf;
+using Humanizer;
 
 namespace DesktopClock;
 
@@ -29,7 +30,7 @@ public class MainViewModel : ViewModelBase
     /// </summary>
     public string CurrentTimeOrCountdownString =>
         IsCountdown ?
-        (Settings.Default.CountdownTo - DateTimeOffset.Now).ToString(Settings.Default.Format) :
+        Settings.Default.CountdownTo.Humanize(CurrentTimeInSelectedTimeZone) :
         CurrentTimeInSelectedTimeZone.ToString(Settings.Default.Format);
 
     /// <summary>