On Tue, Oct 27, 2015 at 07:30:13PM +0000, Nathan Wagner wrote:
> On Wed, Oct 28, 2015 at 08:17:25AM +1300, Gavin Flower wrote:
> > You trying to get PostgreSQL banned in France??? :-)
> >
> > When I was learning French many years ago, I was told that the French
> > consider their fortnight to be 15 days!!!
>
> What, it's a "fortnight", not a "quinzaine".
>
> You have no idea how hard it was to resist updating the patch...
Well, if you won't do it, I will.
Please find attached.
Cheers,
David.
--
David Fetter <[email protected]> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: [email protected]
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 926358e..8a62d65 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -186,6 +186,8 @@ static const datetkn deltatktbl[] = {
{DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */
{"decades", UNITS, DTK_DECADE}, /* "decades" relative */
{"decs", UNITS, DTK_DECADE}, /* "decades" relative */
+ {DFORTNIGHT, UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */
+ {"fortnights", UNITS, DTK_FORTNIGHT}, /* "fortnights" relative */
{"h", UNITS, DTK_HOUR}, /* "hour" relative */
{DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */
{"hours", UNITS, DTK_HOUR}, /* "hours" relative */
@@ -214,6 +216,8 @@ static const datetkn deltatktbl[] = {
{"msecs", UNITS, DTK_MILLISEC},
{"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */
{DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */
+ {DQUINZAINE, UNITS, DTK_QUINZAINE}, /* "quinzaines" relative */
+ {"quinzaines", UNITS, DTK_QUINZAINE}, /* "quinzaines" relative */
{"s", UNITS, DTK_SECOND},
{"sec", UNITS, DTK_SECOND},
{DSECOND, UNITS, DTK_SECOND},
@@ -3281,6 +3285,18 @@ DecodeInterval(char **field, int *ftype, int nf, int
range,
tmask = DTK_M(DAY);
break;
+ case DTK_FORTNIGHT:
+ tm->tm_mday += val * 14;
+ AdjustFractDays(fval, tm, fsec,
14);
+ tmask = DTK_M(WEEK);
+ break;
+
+ case DTK_QUINZAINE:
+ tm->tm_mday += val * 15;
+ AdjustFractDays(fval, tm, fsec,
15);
+ tmask = DTK_M(WEEK);
+ break;
+
case DTK_WEEK:
tm->tm_mday += val * 7;
AdjustFractDays(fval, tm, fsec,
7);
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index e9a1ece..3944912 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -52,6 +52,8 @@ struct tzEntry;
#define DHOUR "hour"
#define DDAY "day"
#define DWEEK "week"
+#define DFORTNIGHT "fortnight"
+#define DQUINZAINE "quinzaine"
#define DMONTH "month"
#define DQUARTER "quarter"
#define DYEAR "year"
@@ -181,6 +183,8 @@ struct tzEntry;
#define DTK_TZ_MINUTE 35
#define DTK_ISOYEAR 36
#define DTK_ISODOW 37
+#define DTK_FORTNIGHT 38
+#define DTK_QUINZAINE 39
/*
diff --git a/src/test/regress/expected/interval.out
b/src/test/regress/expected/interval.out
index c873a99..350f097 100644
--- a/src/test/regress/expected/interval.out
+++ b/src/test/regress/expected/interval.out
@@ -40,6 +40,18 @@ SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours";
10 days 12:00:00
(1 row)
+SELECT INTERVAL '1 fortnight' AS "Fourteen days";
+ Fourteen days
+---------------
+ 14 days
+(1 row)
+
+SELECT INTERVAL '1 quinzaine' AS "Fifteen days";
+ Fifteen days
+--------------
+ 15 days
+(1 row)
+
SELECT INTERVAL '1.5 months' AS "One month 15 days";
One month 15 days
-------------------
diff --git a/src/test/regress/sql/interval.sql
b/src/test/regress/sql/interval.sql
index 789c3de..ae884bc 100644
--- a/src/test/regress/sql/interval.sql
+++ b/src/test/regress/sql/interval.sql
@@ -12,6 +12,8 @@ SELECT INTERVAL '-08:00' AS "Eight hours";
SELECT INTERVAL '-1 +02:03' AS "22 hours ago...";
SELECT INTERVAL '-1 days +02:03' AS "22 hours ago...";
SELECT INTERVAL '1.5 weeks' AS "Ten days twelve hours";
+SELECT INTERVAL '1 fortnight' AS "Fourteen days";
+SELECT INTERVAL '1 quinzaine' AS "Fifteen days";
SELECT INTERVAL '1.5 months' AS "One month 15 days";
SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years...";
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers