Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8e6b74e

Browse files
author
Michael Meskes
committed
Fixed bug in day of week processing.
1 parent 8860510 commit 8e6b74e

File tree

5 files changed

+7
-17
lines changed

5 files changed

+7
-17
lines changed

src/interfaces/ecpg/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,10 @@ Fri Sep 26 17:14:07 CEST 2003
16651665
Fri Oct 3 12:04:57 CEST 2003
16661666

16671667
- Hide Informix datatypes in PostgreSQL built process.
1668+
1669+
Sun Oct 5 13:08:47 CEST 2003
1670+
1671+
- Fixed bug in day of week calculation.
16681672
- Set ecpg version to 3.0.0
16691673
- Set ecpg library to 4.0.0
16701674
- Set pgtypes library to 1.0.0

src/interfaces/ecpg/pgtypeslib/datetime.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ int
123123
PGTYPESdate_dayofweek(date dDate)
124124
{
125125
/*
126-
* Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
126+
* Sunday: 0 Monday: 1 Tuesday: 2 Wednesday: 3
127127
* Thursday: 4 Friday: 5 Saturday: 6
128128
*/
129-
return 6 - j2day(dDate + 3);
129+
return (int) (dDate + date2j(2000, 1, 1) + 1) % 7;
130130
}
131131

132132
void

src/interfaces/ecpg/pgtypeslib/dt.h

-2
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ int tm2timestamp(struct tm *, fsec_t, int *, timestamp *);
300300
int DecodeUnits(int field, char *lowtoken, int *val);
301301
bool ClearDateCache(bool, bool, bool);
302302

303-
int j2day(int jd);
304-
305303
bool CheckDateTokenTables(void);
306304

307305
int EncodeDateOnly(struct tm *, int, char *, bool);

src/interfaces/ecpg/pgtypeslib/dt_common.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -637,17 +637,6 @@ j2date(int jd, int *year, int *month, int *day)
637637
return;
638638
} /* j2date() */
639639

640-
int
641-
j2day(int date)
642-
{
643-
unsigned int day;
644-
645-
day = date;
646-
day += 1;
647-
day %= 7;
648-
return (int) day;
649-
} /* j2day() */
650-
651640
/* DecodeSpecial()
652641
* Decode text string using lookup table.
653642
* 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
931920
/* Backward-compatible with traditional Postgres abstime dates */
932921

933922
day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
934-
tm->tm_wday = j2day(day);
923+
tm->tm_wday = (int) ((day + date2j(2000, 1, 1) + 1) % 7);
935924

936925
strncpy(str, days[tm->tm_wday], 3);
937926
strcpy((str + 3), " ");

src/interfaces/ecpg/pgtypeslib/timestamp.c

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "dt.h"
1212
#include "pgtypes_timestamp.h"
1313
#include "pgtypes_date.h"
14-
#include "datetime.h"
1514

1615
int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *,
1716
int *, int *, int *, int *);

0 commit comments

Comments
 (0)