Hello Mikko,
There is a a small bug in recent Director functionality, though I can't recognize is it a code problem or a directive trouble (#if !NET5_0_OR_GREATER || WINDOWS_UWP)
I'm working with Activity Calendar object, Passive calendar tab, Day profile tab.
While trying to add day profile action with a start time field "00:00:00", I'v got a message that string is not recongized as a valid DateTime Value.
I checked same action in quite an old Director version (may be 6 months old, let's name it "old source") - no problem, so i just made a little comparative debug.
"old source" of GxDateTime.cs (first "if" branch executed at my PC, so str = "M/d/yyyy HH:mm:ss";) ( private static string GetDateTimeFormat(CultureInfo culture))
#if !NET5_0_OR_GREATER || WINDOWS_UWP
str = "M/d/yyyy HH:mm:ss";
#else
str = culture.DateTimeFormat.ShortDatePattern + " " + culture.DateTimeFormat.LongTimePattern;
#if !WINDOWS_UWP
"new source" of GxDateTime.cs (no branch, just read culture) ( private static string GetDateTimeFormat(CultureInfo culture)):
string str = culture.DateTimeFormat.ShortDatePattern + " " + culture.DateTimeFormat.LongTimePattern;
"old version" of GxDateTime.cs (mine executable branch is string timeSeparator = ":"; string dateSeparator = "/"; )
private void Remove(StringBuilder format, CultureInfo culture)
{
#if !NET5_0_OR_GREATER || WINDOWS_UWP
string timeSeparator = ":";
string dateSeparator = "/";
#else
string timeSeparator = culture.DateTimeFormat.TimeSeparator;
string dateSeparator = culture.DateTimeFormat.DateSeparator;
#endif //!WINDOWS_UWP
"new version" of GxDateTime.cs (mine executable branch is string string timeSeparator = ":"; string dateSeparator = "/";)
private void Remove(StringBuilder format, CultureInfo culture)
{
#if !NET5_0_OR_GREATER || WINDOWS_UWP
string timeSeparator = ":";
string dateSeparator = "/";
#else
string timeSeparator = culture.DateTimeFormat.TimeSeparator;
string dateSeparator = culture.DateTimeFormat.DateSeparator;
#endif //!WINDOWS_UWP
So, in "old version" used date separator always "/", though it is differ from culture settings, it works ok.
In "new version " used date separator is read from culture in private static string GetDateTimeFormat(CultureInfo culture), and still uses "/" in Remove, so this results to a bug, because my system date separator (from culture) (".") is not removed from string.
Best regards, Andrew
Hi Andrew, If you add the…
Hi Andrew,
If you add the start time, the date-separator is not used.
You didn't tell what .Net version and language you are using, but the time separator can also be in format 00.00.00.
The correct date and time formats depend on the localization settings used.
Check first is your using 00.00.00 or 00:00:00 format.
BR,
Mikko
Hi Mikko, as written in…
Hi Mikko,
as written in Visual Studio "About" dialog, I'm using "Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.12.3", Microsoft .NET Framework version 4.8.04084
As for "If you add the start time, the date-separator is not used":
- just after entering "00:00:00" in "start time" field (yes, I have 00:00:00 format ) we are dropping to public GXDateTime(string value, CultureInfo culture) with value="00:00:00", this step is ok
- in format.Append(GetDateTimeFormat(culture)); result format is "{dd.MM.yyyy H:mm:ssdd.MM.yyyy H:mm:ss}", this step is ok
- after that we drops to private void Remove(StringBuilder format, CultureInfo culture)
string dateSeparator = "/"; (this step is not ok)
- next steps
else if (this is GXTime)
{
Remove(format, "yyyy", dateSeparator);
Remove(format, "yy", dateSeparator);
Remove(format, "MM", dateSeparator);
Remove(format, "M", dateSeparator);
Remove(format, "dd", dateSeparator);
Remove(format, "d", dateSeparator);
each one is using dateSeparator as "/"
so resulting "fromat " value is "{.. H:mm:ss.. H:mm:ss}" (dd, mm, YYYY removed, "." date separators readed from culture are not removed) - this is wrong
and the final problem i at line
Value = DateTime.ParseExact(v, format.ToString(), culture); (of public GXDateTime(string value, CultureInfo culture))
here v is "00:00:00"
format is "{.. H:mm:ss.. H:mm:ss}" ("." date separators not removed, incorrect)
so at DateTime.ParseExact I'be got an exception
Hello Andrew, This problem…
Hello Andrew,
This problem can't be repeated. Are you using am or pm? If you do, then you need to add it also. Like this: "12:00:00 am".
BR,
Mikko
Hello Mikko, to reproduce a…
Hello Mikko,
to reproduce a problem, just set your region format in Windows "Region" dialog to "German(Germany)", where "short date" field is dd.MM.yyyy
Unfortunately, can't attach a screenshot here. I'm ready to send all the pictures if it helps.
Best regards, Andrew
Hi Andrew, After the region…
Hi Andrew,
After the region was changed to Germany, this was able to be repeated. This is fixed in the next version.
BR,
Mikko
Hi Andrew, This is now fixed…
Hi Andrew,
This is now fixed, and the new version has been released. This was clear after the language was changed to German.
Thank you for pointing this out.
BR,
Mikko
Thanks a lot!
Thanks a lot!