Skip to content

Commit e4dcf64

Browse files
Add configuration to set the behavior or add operations on empty dates to the previous one. (#510)
1 parent 72eba0c commit e4dcf64

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,13 +2640,13 @@ public string Time()
26402640

26412641
static public DateTime AddMth(DateTime dt, int cantMonths)
26422642
{
2643-
if (dt == nullDate && cantMonths < 0)
2643+
if (dt == nullDate && (cantMonths < 0 || Preferences.IgnoreAddOnEmptyDates))
26442644
return nullDate;
26452645
return dt.AddMonths(cantMonths);
26462646
}
26472647
static public DateTime AddYr(DateTime dt, int cantYears)
26482648
{
2649-
if (dt == nullDate && cantYears < 0)
2649+
if (dt == nullDate && (cantYears < 0 || Preferences.IgnoreAddOnEmptyDates))
26502650
return nullDate;
26512651
return dt.AddYears(cantYears);
26522652
}
@@ -2701,13 +2701,13 @@ static public int DDiff(DateTime dtMinu, DateTime dtSust)
27012701
}
27022702
static public DateTime TAdd(DateTime dt, int seconds)
27032703
{
2704-
if (dt == nullDate && seconds < 0)
2704+
if (dt == nullDate && (seconds < 0 || Preferences.IgnoreAddOnEmptyDates))
27052705
return nullDate;
27062706
return dt.AddSeconds(seconds);
27072707
}
27082708
static public DateTime TAddMs(DateTime dt, double seconds)
27092709
{
2710-
if (dt == nullDate && seconds < 0)
2710+
if (dt == nullDate && (seconds < 0 || Preferences.IgnoreAddOnEmptyDates))
27112711
return nullDate;
27122712
if (seconds % 1 == 0)
27132713
return dt.AddSeconds((int)seconds);
@@ -2716,7 +2716,7 @@ static public DateTime TAddMs(DateTime dt, double seconds)
27162716
}
27172717
static public DateTime DAdd(DateTime dt, int days)
27182718
{
2719-
if (dt == nullDate && days < 0)
2719+
if (dt == nullDate && (days < 0 || Preferences.IgnoreAddOnEmptyDates))
27202720
return nullDate;
27212721
return dt.AddDays(days);
27222722
}

dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ public class Preferences
727727
static string blobPath;
728728
static string blobPathFolderName;
729729
static int blankEmptyDates = -1;
730+
static int ignoreAddOnEmptyDate = -1;
730731
static int setupDB = -1;
731732
static HTMLDocType docType = HTMLDocType.UNDEFINED;
732733
static int docTypeDTD = -1;
@@ -898,7 +899,29 @@ public static bool Remote
898899
}
899900

900901
}
902+
public static bool IgnoreAddOnEmptyDates
903+
{
904+
get
905+
{
906+
if (ignoreAddOnEmptyDate == -1)
907+
{
908+
string val;
909+
if (Config.GetValueOf("IGNORE_ADD_ON_EMPTY_DATE", out val) && val == "1")
910+
{
911+
ignoreAddOnEmptyDate = 1;
912+
return true;
913+
}
914+
else
915+
{
916+
ignoreAddOnEmptyDate = 0;
917+
return false;
918+
}
919+
}
920+
else return (ignoreAddOnEmptyDate == 1);
921+
}
901922

923+
}
924+
902925
public static bool BlankEmptyDates
903926
{
904927
get

0 commit comments

Comments
 (0)