summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
authorMichael Meskes2003-10-05 11:12:00 +0000
committerMichael Meskes2003-10-05 11:12:00 +0000
commit8e6b74e4fdc5e976862a1a82233d009765132aef (patch)
treeca0f14afdf3a0277971886ee1e6395dca1f5b727 /src/interfaces
parent88605109db36dcdb4e4267968ec4acc74311fea9 (diff)
Fixed bug in day of week processing.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/ecpg/ChangeLog4
-rw-r--r--src/interfaces/ecpg/pgtypeslib/datetime.c4
-rw-r--r--src/interfaces/ecpg/pgtypeslib/dt.h2
-rw-r--r--src/interfaces/ecpg/pgtypeslib/dt_common.c13
-rw-r--r--src/interfaces/ecpg/pgtypeslib/timestamp.c1
5 files changed, 7 insertions, 17 deletions
diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index e69457d673e..a99adf1fd52 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -1665,6 +1665,10 @@ Fri Sep 26 17:14:07 CEST 2003
Fri Oct 3 12:04:57 CEST 2003
- Hide Informix datatypes in PostgreSQL built process.
+
+Sun Oct 5 13:08:47 CEST 2003
+
+ - Fixed bug in day of week calculation.
- Set ecpg version to 3.0.0
- Set ecpg library to 4.0.0
- Set pgtypes library to 1.0.0
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index 2b5e1c93e83..9e951022f9a 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -123,10 +123,10 @@ int
PGTYPESdate_dayofweek(date dDate)
{
/*
- * Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
+ * Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
* Thursday: 4 Friday: 5 Saturday: 6
*/
- return 6 - j2day(dDate + 3);
+ return (int) (dDate + date2j(2000, 1, 1) + 1) % 7;
}
void
diff --git a/src/interfaces/ecpg/pgtypeslib/dt.h b/src/interfaces/ecpg/pgtypeslib/dt.h
index f745bf2756d..2cbc58984bd 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt.h
+++ b/src/interfaces/ecpg/pgtypeslib/dt.h
@@ -300,8 +300,6 @@ int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
int DecodeUnits(int field, char *lowtoken, int *val);
bool ClearDateCache(bool, bool, bool);
-int j2day(int jd);
-
bool CheckDateTokenTables(void);
int EncodeDateOnly(struct tm *, int, char *, bool);
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c
index af9638ddc01..04aaa70ccfc 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt_common.c
+++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c
@@ -637,17 +637,6 @@ j2date(int jd, int *year, int *month, int *day)
return;
} /* j2date() */
-int
-j2day(int date)
-{
- unsigned int day;
-
- day = date;
- day += 1;
- day %= 7;
- return (int) day;
-} /* j2day() */
-
/* DecodeSpecial()
* Decode text string using lookup table.
* Implement a cache lookup since it is likely that dates
@@ -931,7 +920,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
/* Backward-compatible with traditional Postgres abstime dates */
day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
- tm->tm_wday = j2day(day);
+ tm->tm_wday = (int) ((day + date2j(2000, 1, 1) + 1) % 7);
strncpy(str, days[tm->tm_wday], 3);
strcpy((str + 3), " ");
diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c
index 473fad5af97..ee7fa3b4f81 100644
--- a/src/interfaces/ecpg/pgtypeslib/timestamp.c
+++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c
@@ -11,7 +11,6 @@
#include "dt.h"
#include "pgtypes_timestamp.h"
#include "pgtypes_date.h"
-#include "datetime.h"
int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *,
int *, int *, int *, int *);