diff options
-rw-r--r-- | npc/003-3/malindou.txt | 3 | ||||
-rw-r--r-- | npc/functions/util.txt | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/npc/003-3/malindou.txt b/npc/003-3/malindou.txt index 25d3fe935..ad54b65cd 100644 --- a/npc/003-3/malindou.txt +++ b/npc/003-3/malindou.txt @@ -656,7 +656,8 @@ OnInit: end; OnClock0500: - query_sql("DELETE FROM `chatlog` WHERE `time` < '"+sqldate(-7)+"'"); + if (gettime(GETTIME_DAYOFMONTH) >= 7) + query_sql("DELETE FROM `chatlog` WHERE `time` < '"+sqldate(-7)+"'"); end; // This is for HUB diff --git a/npc/functions/util.txt b/npc/functions/util.txt index 5afbdbce1..1966ce6df 100644 --- a/npc/functions/util.txt +++ b/npc/functions/util.txt @@ -1147,8 +1147,13 @@ function script numdate { // Same as numdate() but SQL format. // sqldate({day variation}) function script sqldate { - .@d=getarg(0, 0); - .@strdate$=sprintf("%04d-%02d-%02d %02d:%02d:%02d", gettime(GETTIME_YEAR), gettime(GETTIME_MONTH), gettime(GETTIME_DAYOFMONTH)+.@d, gettime(GETTIME_HOUR), gettime(GETTIME_MINUTE), gettime(GETTIME_SECOND)); + .@d=gettime(GETTIME_DAYOFMONTH)+getarg(0, 0); + .@m=gettime(GETTIME_MONTH); + // Overflow prevention + if (.@d <= 0) { + .@d=1; + } + .@strdate$=sprintf("%04d-%02d-%02d %02d:%02d:%02d", gettime(GETTIME_YEAR), .@m, .@d, gettime(GETTIME_HOUR), gettime(GETTIME_MINUTE), gettime(GETTIME_SECOND)); return .@strdate$; } |