Skip to content

Commit

Permalink
#115 Debugging a CI build issue regarding client vs server timezones,…
Browse files Browse the repository at this point in the history
… seemingly default CultureInfo cannot TryParse our database format, added explicit format and fixed the yyyy typo
  • Loading branch information
ddemeyer committed Sep 28, 2021
1 parent 0904e36 commit 48c6bb5
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace Trisoft.ISHRemote.HelperClasses
// . https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.psvariable?view=powershellsdk-1.1.0
internal class NameHelper
{
private readonly CultureInfo _cultureInfoEnUs = new CultureInfo("en-US");
private readonly IshSession _ishSession;
private readonly string _levelNameValueTypeSeparator = "_"; // Not that many special characters allowed in Properties, e.g. '=' is assignment
// TODO [Could] NameHelper PSNoteProperty generator could benefit of fast-lookup dictionary to store DataType and PropertyName as almost all IshObjects start from the same requested metadata request...
Expand Down Expand Up @@ -100,14 +99,14 @@ public PSNoteProperty GetPSNoteProperty(Enumerations.ISHType[] ishTypes, IshMeta
// or ISO8601 (ToString('s', dt)) yyyy-MM-ddTHH:mm:ss (similar format 'u' add time zone which I consider non-scope for now)
// Note that TranslationJob's LEASEDON is returned by the API in Utc.
case Enumerations.DataType.DateTime:
//var formatStrings = new string[] { "dd/MM/yyy HH:mm:ss", "yyyy-MM-dd hh:mm:ss", "dd/MM/yyy" };
//var formatStrings = new string[] { "dd/MM/yyyy HH:mm:ss", "yyyy-MM-dd hh:mm:ss", "dd/MM/yyy" };
DateTime dateTime;
if (DateTime.TryParse(ishField.Value, out dateTime))
{
propertyValue = dateTime.ToString("s");
}
//seemingly Github Actions CI/CD is running a CultureInfo which makes the above generic TryParse fail, so trying an explicit one
else if (DateTime.TryParseExact(ishField.Value, "dd/MM/yyy HH:mm:ss", _cultureInfoEnUs, DateTimeStyles.None, out dateTime))
else if (DateTime.TryParseExact(ishField.Value, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
{
propertyValue = dateTime.ToString("s");
}
Expand Down

0 comments on commit 48c6bb5

Please sign in to comment.