From e0fc47a14112806db70e9233174ac2ee651291cb Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Wed, 5 Dec 2018 23:47:16 +0100 Subject: [PATCH] Fix calcolo datetime invariante su lingua... --- SteamWareLib/memLayer.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/SteamWareLib/memLayer.cs b/SteamWareLib/memLayer.cs index 582f9d9..a4e7fba 100644 --- a/SteamWareLib/memLayer.cs +++ b/SteamWareLib/memLayer.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Configuration; using System.Data; +using System.Globalization; using System.Web; namespace SteamWare @@ -229,8 +230,15 @@ namespace SteamWare { // se è in cache if (isInCacheObject("lastUpdateAppConf")) - { - answ = Convert.ToDateTime(objCacheObj("lastUpdateAppConf")); + { + // faccio SEMPRE calcolo esatto sennò sbaglia... + CultureInfo provider = CultureInfo.InvariantCulture; + string format = "yyyy-MM-dd HH:mm:ss"; + answ = DateTime.ParseExact(objCacheObj("lastUpdateAppConf").ToString(), format, provider); +#if false + // mi aspetto formato standard... + answ = Convert.ToDateTime(objCacheObj("lastUpdateAppConf")); +#endif } } catch (Exception exc) @@ -241,7 +249,12 @@ namespace SteamWare } set { - setCacheVal("lastUpdateAppConf", value, true); + // faccio SEMPRE calcolo esatto sennò sbaglia... + CultureInfo provider = CultureInfo.InvariantCulture; + string format = "yyyy-MM-dd HH:mm:ss"; + string valore = value.ToString(format, provider); + // ora salvo! + setCacheVal("lastUpdateAppConf", valore, true); } } @@ -1179,7 +1192,7 @@ namespace SteamWare answ = redVal != null && redVal != ""; } } - catch(Exception exc) + catch (Exception exc) { logger.lg.scriviLog(string.Format("Errore in verifica isInCacheObject REDIS per chiave{0}{1}{2}", nomeVar, Environment.NewLine, exc)); }