Skip to content

Commit 1651127

Browse files
committed
Update date check
1 parent 8d7a678 commit 1651127

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

BabylonJS_Installer/BabylonJS_Installer/SoftwareChecker.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.Win32;
22
using System;
33
using System.Collections.Generic;
4+
using System.Globalization;
45
using System.IO;
56
using System.Security.Principal;
67
using System.Threading.Tasks;
@@ -135,29 +136,23 @@ public void setLatestVersionDate()
135136
Task<string> jsonRequest = Task.Run(async () => { return await downloader.GetJSONBodyRequest(downloader.GetURLGitHubAPI()); });
136137
//TO DO Find a better way to parse JSON aswell
137138
string json = jsonRequest.Result;
138-
string published_at = json.Substring(json.IndexOf("\"published_at\":"));
139-
published_at = published_at.Remove(published_at.IndexOf("\","));
140-
this.latestVersionDate = published_at.Remove(0, "\"published_at\":\"".Length);
139+
string created_at = json.Substring(json.IndexOf("\"created_at\":"));
140+
created_at = created_at.Remove(created_at.IndexOf("\","));
141+
this.latestVersionDate = created_at.Remove(0, "\"created_at\":\"".Length);
141142
}
142143

143144
public bool isLatestVersionInstalled(string soft, string version, string location)
144145
{// To ensure latest version, we compare between last modified time of files and the publish date of github release
145-
string[] latestDateSplit = this.latestVersionDate.Split('-');
146-
string year = latestDateSplit[0];
147-
string month = latestDateSplit[1];
148-
string day = latestDateSplit[2].Substring(0, 2);
149-
bool isLatestversion = false;
150-
string lastUpdate = "";
146+
var latest = DateTime.Parse(this.latestVersionDate, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
147+
var isLatestversion = false;
151148
switch (soft)
152149
{
153150
case "Max":
154-
lastUpdate = File.GetLastWriteTime(location + "bin\\assemblies\\Max2Babylon.dll").ToString();
155-
if (lastUpdate.Contains(year) && lastUpdate.Contains(month) && lastUpdate.Contains(day)) isLatestversion = true;
151+
if (latest <= File.GetLastWriteTime(location + "bin\\assemblies\\Max2Babylon.dll")) isLatestversion = true;
156152
break;
157153

158154
case "Maya":
159-
lastUpdate = File.GetLastWriteTime(location + "bin\\plug-ins\\Maya2Babylon.nll.dll").ToString();
160-
if (lastUpdate.Contains(year) && lastUpdate.Contains(month) && lastUpdate.Contains(day)) isLatestversion = true;
155+
if (latest <= File.GetLastWriteTime(location + "bin\\plug-ins\\Maya2Babylon.nll.dll")) isLatestversion = true;
161156
break;
162157

163158
default:

0 commit comments

Comments
 (0)