Skip to content

Commit

Permalink
Fix date not localized
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Oct 29, 2023
1 parent a39959e commit b6851e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion GetMyIP/Helpers/MainWindowHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ internal static void LogStartup()
// Log the version, build date and commit id
_log.Info($"{AppInfo.AppName} ({AppInfo.AppProduct}) {AppInfo.AppVersion} {GetStringResource("MsgText_ApplicationStarting")}");
_log.Info($"{AppInfo.AppName} {AppInfo.AppCopyright}");
_log.Debug($"{AppInfo.AppName} Build date: {BuildInfo.BuildDateString} (UTC)");
_log.Debug($"{AppInfo.AppName} Build date: {BuildInfo.BuildDateStringUtc}");
_log.Debug($"{AppInfo.AppName} Commit ID: {BuildInfo.CommitIDString}");
_log.Debug($"{AppInfo.AppName} was started from {AppInfo.AppPath}");
if (IsAdministrator())
Expand Down
9 changes: 6 additions & 3 deletions GetMyIP/PowerShell/GenBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[Parameter(Mandatory = $false)] [string] $outputFile="BuildInfo.cs"
)

$nowUTC = (Get-Date).ToUniversalTime()
$nowUTC = (Get-Date).ToUniversalTime().ToString('yyyy/MM/dd HH:mm:ss')

$commitID = git rev-parse --short HEAD
if ($commitID.Length -lt 1 ) {
Expand Down Expand Up @@ -34,9 +34,12 @@ public static class BuildInfo
public const string BuildDateString = `"$nowUTC`";
public const string BuildDateUtcString = `"$nowUTC (UTC)`";
public static readonly DateTime BuildDateUtc =
DateTime.SpecifyKind(
DateTime.ParseExact(BuildDateString, `"yyyy/MM/dd HH:mm:ss`", CultureInfo.InvariantCulture),
DateTimeKind.Utc);
public static readonly DateTime BuildDateUtc = DateTime.SpecifyKind(DateTime.Parse(BuildDateString), DateTimeKind.Utc);
public static readonly string BuildDateStringUtc = $`"{BuildDateUtc:f} (UTC)`";
public static readonly DateTime BuildDateLocal = BuildDateUtc.ToLocalTime();
}"
Expand Down
4 changes: 2 additions & 2 deletions GetMyIP/Views/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@

<TextBlock Grid.Row="5" Grid.Column="0"
Text="{DynamicResource About_BuildDate}" />
<TextBlock Grid.Row="5" Grid.Column="2"
Text="{x:Static local:BuildInfo.BuildDateUtcString}" />
<TextBlock Text="{x:Static local:BuildInfo.BuildDateStringUtc}"
Grid.Row="5" Grid.Column="2" />

<TextBlock Grid.Row="6" Grid.Column="0"
Text="{DynamicResource About_CommitID}" />
Expand Down

0 comments on commit b6851e5

Please sign in to comment.