DCL 4.1
Loading...
Searching...
No Matches
PgTypes_.h File Reference

Go to the source code of this file.

Macros

#define __DCL_PG_TYPES_H__   20250406

Functions

__DCL_BEGIN_NAMESPACE void __decode (const date *_s, SQL::Date *_r)
void __encode (const SQL::Date *_s, date *_r)
void __decode (const char *_s, SQL::Time *_r)
ByteString __encode (const SQL::Time *_s)
void __decode (const timestamp *_s, SQL::TimeStamp *_r)
void __encode (const SQL::TimeStamp *_s, timestamp *_r)
void __decode (const interval *_s, SQL::Interval *_r)
void __encode (const SQL::Interval *_s, interval *_r)

Macro Definition Documentation

◆ __DCL_PG_TYPES_H__

#define __DCL_PG_TYPES_H__   20250406

Definition at line 2 of file PgTypes_.h.

Function Documentation

◆ __decode() [1/4]

void __decode ( const char * _s,
SQL::Time * _r )

Definition at line 49 of file PgTypes.cpp.

50{
51 int h, m, s, f;
52 (void) sscanf(_s, __TIME_FORMAT, &h, &m, &s, &f);
53 _r->hour = h;
54 _r->min = m;
55 _r->sec = s;
56 _r->frac = f * 10000;
57 _r->tzoff = INT16_MIN;
58}
#define INT16_MIN
Definition Config.h:312
_r
Definition SQLField.cpp:261

◆ __decode() [2/4]

__DCL_BEGIN_NAMESPACE void __decode ( const date * _s,
SQL::Date * _r )

Definition at line 27 of file PgTypes.cpp.

28{
29 int mdy[3];
30 PGTYPESdate_julmdy(*_s, mdy);
31 _r->month = mdy[0];
32 _r->day = mdy[1];
33 _r->year = mdy[2] - (*_s < 730119 ? 1 : 0);
34 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n", *_s, mdy[0], mdy[1], mdy[2]);
35}

◆ __decode() [3/4]

void __decode ( const interval * _s,
SQL::Interval * _r )

Definition at line 111 of file PgTypes.cpp.

112{
113 //__DCL_TRACE2(L"month[%ld] time[%lld]\n", _s->month, _s->time);
114 _r->years = _s->month / 12;
115 _r->months = _s->month % 12;
116
117 _r->fracs = (_s->time % 1000000) * 1000;
118 int64_t t = _s->time / 1000000;
119 _r->secs = t % 60;
120 t /= 60;
121 _r->mins = t % 60;
122 t /= 60;
123 _r->hours = t % 24;
124 _r->days = (int) (t / 24);
125}

◆ __decode() [4/4]

void __decode ( const timestamp * _s,
SQL::TimeStamp * _r )

Definition at line 66 of file PgTypes.cpp.

67{
68 // PostgreSQL timestamp API에서 TZ는 무시된다.
69 char sz[40]; // 2025-04-07 10:09:49 +0900 25
70 int r = PGTYPEStimestamp_fmt_asc((timestamp*) _s, sz, sizeof(sz),
71 "%Y-%m-%d %H:%M:%S %z");
72 //__DCL_TRACE2(L"[%lld][%hs]\n", *_s, sz);
73 int Y, m, d, H, M, S, tzhour, tzmin;
74 (void) sscanf(sz, "%d-%02u-%02u %02u:%02u:%02u %3d%02u",
75 &Y, &m, &d, &H, &M, &S, &tzhour, &tzmin);
76 _r->year = Y - (*_s < -63082281600000000LL ? 1 : 0);
77 _r->month = m;
78 _r->day = d;
79 _r->hour = H;
80 _r->min = M;
81 _r->sec = S;
82 _r->frac = 0;
83 _r->tzoff = INT16_MIN; // (tzhour * 60) + tzmin;
84 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n", Y, m, d, H);
85 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n", M, S, tzhour, tzmin);
86}
#define H(x, y, z)
Definition MD5.cpp:175
ByteString r

◆ __encode() [1/4]

void __encode ( const SQL::Date * _s,
date * _r )

Definition at line 37 of file PgTypes.cpp.

38{
39 int mdy[3];
40 mdy[0] = _s->month;
41 mdy[1] = _s->day;
42 mdy[2] = _s->year;
43 PGTYPESdate_mdyjul(mdy, _r);
44}
int16_t year
Definition SQLCore.h:97
uint8_t month
Definition SQLCore.h:98
uint8_t day
Definition SQLCore.h:99

◆ __encode() [2/4]

void __encode ( const SQL::Interval * _s,
interval * _r )

Definition at line 127 of file PgTypes.cpp.

128{
129 //__DCL_TRACE3(L"[%d][%d][%d]\n", _s->years, _s->months, _s->days);
130 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n",
131 // _s->hours, _s->mins, _s->secs, _s->fracs);
132 _r->month = _s->years * 12 + _s->months;
133 _r->time = (_s->fracs / 1000LL)
134 + (_s->secs * 1000000LL)
135 + (_s->mins * 60 * 1000000LL)
136 + (_s->hours * 60 * 60 * 1000000LL)
137 + (_s->days * 24 * 60 * 60 * 1000000LL)
138 ;
139}
int32_t years
Definition SQLCore.h:127
int32_t days
Definition SQLCore.h:129
int8_t hours
Definition SQLCore.h:130
int8_t mins
Definition SQLCore.h:131
int32_t fracs
Definition SQLCore.h:133
int8_t months
Definition SQLCore.h:128
int8_t secs
Definition SQLCore.h:132

◆ __encode() [3/4]

ByteString __encode ( const SQL::Time * _s)

Definition at line 60 of file PgTypes.cpp.

61{
62 return ByteString::format(__TIME_FORMAT,
63 _s->hour, _s->min, _s->sec, _s->frac / 10000);
64}
uint8_t hour
Definition SQLCore.h:104
uint8_t sec
Definition SQLCore.h:106
uint32_t frac
Definition SQLCore.h:107
uint8_t min
Definition SQLCore.h:105

◆ __encode() [4/4]

void __encode ( const SQL::TimeStamp * _s,
timestamp * _r )

Definition at line 93 of file PgTypes.cpp.

94{
95 //int tzhour = 0, tzmin = 0;
96 //if (_s->tzoff != INT16_MIN) {
97 // tzhour = _s->tzoff / 60;
98 // tzmin = __ABS(_s->tzoff % 60);
99 //}
100 char sz[40];
101 int n = snprintf(
102 sz, sizeof(sz), "%04d-%02u-%02u %02u:%02u:%02u",
103 _s->year, _s->month, _s->day,
104 _s->hour, _s->min, _s->sec
105 );
106 //sz[n] = '\0';
107 //__DCL_TRACE1(L"[%hs]\n", sz);
108 PGTYPEStimestamp_defmt_asc(sz, "%Y-%m-%d %H:%M:%S", _r);
109}
void CharsetConvertException *size_t n
Definition SQLField.cpp:254
uint8_t min
Definition SQLCore.h:117
uint8_t sec
Definition SQLCore.h:118
uint8_t hour
Definition SQLCore.h:116
uint8_t day
Definition SQLCore.h:115
int16_t year
Definition SQLCore.h:113
uint8_t month
Definition SQLCore.h:114