diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-02-14 17:10:01 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-02-14 17:10:01 -0300 |
commit | f8a6393d92575f49d0076f13242bc2d0ac06f2e0 (patch) | |
tree | 2aae2312746189eaaac9ed88c97f6482fda8cfb9 /npc/functions | |
parent | bd27276c5b1c9b9057aed7e61df571ec325e1eed (diff) | |
download | serverdata-f8a6393d92575f49d0076f13242bc2d0ac06f2e0.tar.gz serverdata-f8a6393d92575f49d0076f13242bc2d0ac06f2e0.tar.bz2 serverdata-f8a6393d92575f49d0076f13242bc2d0ac06f2e0.tar.xz serverdata-f8a6393d92575f49d0076f13242bc2d0ac06f2e0.zip |
Prevent a few bugs but not all of 'em
Diffstat (limited to 'npc/functions')
-rw-r--r-- | npc/functions/util.txt | 9 |
1 files changed, 7 insertions, 2 deletions
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$; } |