MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / datetime_to_text

Function datetime_to_text

src/common/cvt.cpp:2287–2429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2285
2286
2287static void datetime_to_text(const dsc* from, dsc* to, Callbacks* cb)
2288{
2289/**************************************
2290 *
2291 * d a t e t i m e _ t o _ t e x t
2292 *
2293 **************************************
2294 *
2295 * Functional description
2296 * Convert a timestamp, date or time value to text.
2297 *
2298 **************************************/
2299 bool version4 = true;
2300
2301 fb_assert(DTYPE_IS_TEXT(to->dsc_dtype));
2302
2303 // Convert a date or time value into a timestamp for manipulation
2304
2305 bool tzLookup = true;
2306 tm times;
2307 memset(&times, 0, sizeof(struct tm));
2308
2309 int fractions = 0;
2310 USHORT timezone;
2311
2312 switch (from->dsc_dtype)
2313 {
2314 case dtype_sql_time:
2315 Firebird::TimeStamp::decode_time(*(GDS_TIME*) from->dsc_address,
2316 &times.tm_hour, &times.tm_min, &times.tm_sec, &fractions);
2317 break;
2318
2319 case dtype_sql_time_tz:
2320 case dtype_ex_time_tz:
2321 tzLookup = TimeZoneUtil::decodeTime(*(ISC_TIME_TZ*) from->dsc_address,
2322 true, TimeZoneUtil::NO_OFFSET, &times, &fractions);
2323 timezone = ((ISC_TIME_TZ*) from->dsc_address)->time_zone;
2324 break;
2325
2326 case dtype_sql_date:
2327 Firebird::TimeStamp::decode_date(*(GDS_DATE *) from->dsc_address, &times);
2328 break;
2329
2330 case dtype_timestamp:
2331 cb->isVersion4(version4); // Used in the conversion to text some lines below.
2332 Firebird::TimeStamp::decode_timestamp(*(GDS_TIMESTAMP*) from->dsc_address, &times, &fractions);
2333 break;
2334
2335 case dtype_timestamp_tz:
2336 case dtype_ex_timestamp_tz:
2337 cb->isVersion4(version4); // Used in the conversion to text some lines below.
2338 tzLookup = TimeZoneUtil::decodeTimeStamp(*(ISC_TIMESTAMP_TZ*) from->dsc_address,
2339 true, TimeZoneUtil::NO_OFFSET, &times, &fractions);
2340 timezone = ((ISC_TIMESTAMP_TZ*) from->dsc_address)->time_zone;
2341 break;
2342
2343 default:
2344 fb_assert(false);

Callers 1

CVT_move_commonFunction · 0.85

Calls 11

DTYPE_IS_TEXTFunction · 0.85
decode_timestampFunction · 0.85
GdsClass · 0.85
formatFunction · 0.85
CVT_move_commonFunction · 0.85
isTimeMethod · 0.80
isTimeStampMethod · 0.80
isDateTimeTzMethod · 0.80
dsc_ttypeMethod · 0.80
isTextMethod · 0.80
isVersion4Method · 0.45

Tested by

no test coverage detected