summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorunknown <gluh@gluh.mysql.r18.ru>2003-10-20 13:24:18 +0500
committerunknown <gluh@gluh.mysql.r18.ru>2003-10-20 13:24:18 +0500
commit299fc6a9f536571998f1fbc69a599800d3c95166 (patch)
treea0500a3926dc01176082cc42ad87fbaed18113b3 /sql/protocol.cc
parentd6f15e9d02d7fb33627c937ff47c948dd9ae0b2e (diff)
downloadmariadb-git-299fc6a9f536571998f1fbc69a599800d3c95166.tar.gz
Scrum task 835 - text-to-datetime conversion function
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc45
1 files changed, 19 insertions, 26 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index d1eb3460fc8..c2d9ccec63a 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -831,17 +831,12 @@ bool Protocol_simple::store(TIME *tm)
field_pos++;
#endif
char buff[40];
- uint length;
- length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
- (int) tm->year,
- (int) tm->month,
- (int) tm->day,
- (int) tm->hour,
- (int) tm->minute,
- (int) tm->second));
- if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part));
- return net_store_data((char*) buff, length);
+ String tmp((char*) buff,sizeof(buff),&my_charset_bin);
+ DATETIME_FORMAT *tmp_format= (&t_datetime_frm
+ (current_thd, DATETIME_FORMAT_TYPE).datetime_format);
+ make_datetime(&tmp, tm, 1, tm->second_part,
+ tmp_format->format, tmp_format->format_length, 1);
+ return net_store_data((char*) tmp.ptr(), tmp.length());
}
@@ -853,12 +848,12 @@ bool Protocol_simple::store_date(TIME *tm)
field_pos++;
#endif
char buff[40];
- uint length;
- length= my_sprintf(buff,(buff, "%04d-%02d-%02d",
- (int) tm->year,
- (int) tm->month,
- (int) tm->day));
- return net_store_data((char*) buff, length);
+ String tmp((char*) buff,sizeof(buff),&my_charset_bin);
+ DATETIME_FORMAT *tmp_format= (&t_datetime_frm
+ (current_thd, DATE_FORMAT_TYPE).datetime_format);
+ make_datetime(&tmp, tm, 1, 0,
+ tmp_format->format, tmp_format->format_length, 1);
+ return net_store_data((char*) tmp.ptr(), tmp.length());
}
@@ -876,16 +871,14 @@ bool Protocol_simple::store_time(TIME *tm)
field_pos++;
#endif
char buff[40];
- uint length;
+ String tmp((char*) buff,sizeof(buff),&my_charset_bin);
+ DATETIME_FORMAT *tmp_format= (&t_datetime_frm
+ (current_thd, TIME_FORMAT_TYPE).datetime_format);
uint day= (tm->year || tm->month) ? 0 : tm->day;
- length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d",
- tm->neg ? "-" : "",
- (long) day*24L+(long) tm->hour,
- (int) tm->minute,
- (int) tm->second));
- if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part));
- return net_store_data((char*) buff, length);
+ tm->hour= (long) day*24L+(long) tm->hour;
+ make_datetime(&tmp, tm, 0, tm->second_part,
+ tmp_format->format, tmp_format->format_length, 1);
+ return net_store_data((char*) tmp.ptr(), tmp.length());
}