aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/datetime.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2021-05-01 10:42:44 -0400
committerBruce Momjian <bruce@momjian.us>2021-05-01 10:42:44 -0400
commit651d005e76bc0b9542615f609b4d0d946035dc58 (patch)
tree091685dde4a23011030907d96d49b8749417cc78 /src/backend/utils/adt/datetime.c
parente6f9539dc32473793c03cbe95bc099ee0a199c73 (diff)
downloadpostgresql-651d005e76bc0b9542615f609b4d0d946035dc58.tar.gz
postgresql-651d005e76bc0b9542615f609b4d0d946035dc58.zip
Revert use singular for -1 (commits 9ee7d533da and 5da9868ed9
Turns out you can specify negative values using plurals: https://english.stackexchange.com/questions/9735/is-1-followed-by-a-singular-or-plural-noun so the previous code was correct enough, and consistent with other usage in our code. Also add comment in the two places where this could be confused. Reported-by: Noah Misch Diagnosed-by: 20210425115726.GA2353095@rfd.leadboat.com
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r--src/backend/utils/adt/datetime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 889077f55c5..54ae632de24 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -4190,7 +4190,7 @@ AddPostgresIntPart(char *cp, int value, const char *units,
(*is_before && value > 0) ? "+" : "",
value,
units,
- (abs(value) != 1) ? "s" : "");
+ (value != 1) ? "s" : "");
/*
* Each nonzero field sets is_before for (only) the next one. This is a
@@ -4216,7 +4216,7 @@ AddVerboseIntPart(char *cp, int value, const char *units,
}
else if (*is_before)
value = -value;
- sprintf(cp, " %d %s%s", value, units, (abs(value) == 1) ? "" : "s");
+ sprintf(cp, " %d %s%s", value, units, (value == 1) ? "" : "s");
*is_zero = false;
return cp + strlen(cp);
}
@@ -4414,6 +4414,7 @@ EncodeInterval(struct pg_tm *tm, fsec_t fsec, int style, char *str)
else if (is_before)
*cp++ = '-';
cp = AppendSeconds(cp, sec, fsec, MAX_INTERVAL_PRECISION, false);
+ /* We output "ago", not negatives, so use abs(). */
sprintf(cp, " sec%s",
(abs(sec) != 1 || fsec != 0) ? "s" : "");
is_zero = false;