DCL 4.0
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->nHour = h;
54 _r->nMin = m;
55 _r->nSec = s;
56 _r->nFrac = f * 10000;
57}
_r
Definition SQLField.cpp:260

◆ __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->nMonth = mdy[0];
32 _r->nDay = mdy[1];
33 _r->nYear = 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 110 of file PgTypes.cpp.

111{
112 //__DCL_TRACE2(L"month[%ld] time[%lld]\n", _s->month, _s->time);
113 _r->nYears = _s->month / 12;
114 _r->nMonths = _s->month % 12;
115
116 _r->nFracs = (_s->time % 1000000) * 1000;
117 int64_t t = _s->time / 1000000;
118 _r->nSecs = t % 60;
119 t /= 60;
120 _r->nMins = t % 60;
121 t /= 60;
122 _r->nHours = t % 24;
123 _r->nDays = (int) (t / 24);
124}

◆ __decode() [4/4]

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

Definition at line 65 of file PgTypes.cpp.

66{
67 // PostgreSQL timestamp API에서 TZ는 무시된다.
68 char sz[40]; // 2025-04-07 10:09:49 +0900 25
69 int r = PGTYPEStimestamp_fmt_asc((timestamp*) _s, sz, sizeof(sz),
70 "%Y-%m-%d %H:%M:%S %z");
71 //__DCL_TRACE2(L"[%lld][%hs]\n", *_s, sz);
72 int Y, m, d, H, M, S, zh, zm;
73 (void) sscanf(sz, "%d-%02u-%02u %02u:%02u:%02u %3d%02u",
74 &Y, &m, &d, &H, &M, &S, &zh, &zm);
75 _r->nYear = Y - (*_s < -63082281600000000LL ? 1 : 0);
76 _r->nMonth = m;
77 _r->nDay = d;
78 _r->nHour = H;
79 _r->nMin = M;
80 _r->nSec = S;
81 _r->nFrac = 0;
82 _r->nTzMin = INT16_MIN; // (zh * 60) + zm;
83 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n", Y, m, d, H);
84 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n", M, S, zh, zm);
85}
#define INT16_MIN
Definition Config.h:312
#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->nMonth;
41 mdy[1] = _s->nDay;
42 mdy[2] = _s->nYear;
43 PGTYPESdate_mdyjul(mdy, _r);
44}
uint8_t nMonth
Definition SQLCore.h:97
int16_t nYear
Definition SQLCore.h:96
uint8_t nDay
Definition SQLCore.h:98

◆ __encode() [2/4]

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

Definition at line 126 of file PgTypes.cpp.

127{
128 //__DCL_TRACE3(L"[%d][%d][%d]\n", _s->nYears, _s->nMonths, _s->nDays);
129 //__DCL_TRACE4(L"[%d][%d][%d][%d]\n",
130 // _s->nHours, _s->nMins, _s->nSecs, _s->nFracs);
131 _r->month = _s->nYears * 12 + _s->nMonths;
132 _r->time = (_s->nFracs / 1000LL)
133 + (_s->nSecs * 1000000LL)
134 + (_s->nMins * 60 * 1000000LL)
135 + (_s->nHours * 60 * 60 * 1000000LL)
136 + (_s->nDays * 24 * 60 * 60 * 1000000LL)
137 ;
138}
int8_t nHours
Definition SQLCore.h:128
int32_t nFracs
Definition SQLCore.h:131
int8_t nSecs
Definition SQLCore.h:130
int8_t nMins
Definition SQLCore.h:129
int32_t nYears
Definition SQLCore.h:125
int8_t nMonths
Definition SQLCore.h:126
int32_t nDays
Definition SQLCore.h:127

◆ __encode() [3/4]

ByteString __encode ( const SQL::Time * _s)

Definition at line 59 of file PgTypes.cpp.

60{
61 return ByteString::format(__TIME_FORMAT,
62 _s->nHour, _s->nMin, _s->nSec, _s->nFrac / 10000);
63}
uint8_t nHour
Definition SQLCore.h:103
uint8_t nMin
Definition SQLCore.h:104
uint8_t nSec
Definition SQLCore.h:105
uint32_t nFrac
Definition SQLCore.h:106

◆ __encode() [4/4]

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

Definition at line 92 of file PgTypes.cpp.

93{
94 //int zh = 0, zm = 0;
95 //if (_s->nTzMin != INT16_MIN) {
96 // zh = _s->nTzMin / 60;
97 // zm = __ABS(_s->nTzMin % 60);
98 //}
99 char sz[40];
100 int n = snprintf(
101 sz, sizeof(sz), "%04d-%02u-%02u %02u:%02u:%02u",
102 _s->nYear, _s->nMonth, _s->nDay,
103 _s->nHour, _s->nMin, _s->nSec
104 );
105 //sz[n] = '\0';
106 //__DCL_TRACE1(L"[%hs]\n", sz);
107 PGTYPEStimestamp_defmt_asc(sz, "%Y-%m-%d %H:%M:%S", _r);
108}
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
int16_t nYear
Definition SQLCore.h:111
uint8_t nDay
Definition SQLCore.h:113
uint8_t nHour
Definition SQLCore.h:114
uint8_t nSec
Definition SQLCore.h:116
uint8_t nMonth
Definition SQLCore.h:112
uint8_t nMin
Definition SQLCore.h:115