[GRASS-SVN] r42866 - grass/trunk/lib/db/dbmi_base
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 20 10:53:03 EDT 2010
Author: aghisla
Date: 2010-07-20 14:53:03 +0000 (Tue, 20 Jul 2010)
New Revision: 42866
Modified:
grass/trunk/lib/db/dbmi_base/datetime.c
Log:
Datetime is now converted to string with leading zeroes for month, day and hour. Proposes to fix the issue in http://lists.osgeo.org/pipermail/grass-dev/2010-July/051239.html
Modified: grass/trunk/lib/db/dbmi_base/datetime.c
===================================================================
--- grass/trunk/lib/db/dbmi_base/datetime.c 2010-07-20 14:10:56 UTC (rev 42865)
+++ grass/trunk/lib/db/dbmi_base/datetime.c 2010-07-20 14:53:03 UTC (rev 42866)
@@ -44,21 +44,21 @@
sprintf(buf, "%d", year);
break;
case DB_MONTH:
- sprintf(buf, "%d%c%d", year, ds, month);
+ sprintf(buf, "%d%c%02d", year, ds, month);
break;
case DB_DAY:
- sprintf(buf, "%d%c%d%c%d", year, ds, month, ds, day);
+ sprintf(buf, "%d%c%02d%c%02d", year, ds, month, ds, day);
break;
case DB_HOUR:
- sprintf(buf, "%d%c%d%c%d %d", year, ds, month, ds, day, hour);
+ sprintf(buf, "%d%c%02d%c%02d %02d", year, ds, month, ds, day, hour);
break;
case DB_MINUTE:
- sprintf(buf, "%d%c%d%c%d %d%c%02d",
+ sprintf(buf, "%d%c%02d%c%02d %02d%c%02d",
year, ds, month, ds, day, hour, ts, minute);
break;
case DB_SECOND:
case DB_FRACTION:
- sprintf(buf, "%d%c%d%c%d %d%c%02d%c%s%.10g",
+ sprintf(buf, "%d%c%02d%c%02d %02d%c%02d%c%s%.10g",
year, ds, month, ds, day, hour, ts, minute, ts, xs,
seconds);
break;
@@ -70,17 +70,17 @@
sprintf(buf, "%d", month);
break;
case DB_DAY:
- sprintf(buf, "%d%c%d", month, ds, day);
+ sprintf(buf, "%02d%c%02d", month, ds, day);
break;
case DB_HOUR:
- sprintf(buf, "%d%c%d %d", month, ds, day, hour);
+ sprintf(buf, "%02d%c%02d %02d", month, ds, day, hour);
break;
case DB_MINUTE:
- sprintf(buf, "%d%c%d %d%c%02d", month, ds, day, hour, ts, minute);
+ sprintf(buf, "%02d%c%02d %02d%c%02d", month, ds, day, hour, ts, minute);
break;
case DB_SECOND:
case DB_FRACTION:
- sprintf(buf, "%d%c%d %d%c%02d%c%s%.10g",
+ sprintf(buf, "%02d%c%02d %02d%c%02d%c%s%.10g",
month, ds, day, hour, ts, minute, ts, xs, seconds);
break;
}
@@ -88,17 +88,17 @@
case DB_DAY:
switch (to) {
case DB_DAY:
- sprintf(buf, "%d", day);
+ sprintf(buf, "%02d", day);
break;
case DB_HOUR:
- sprintf(buf, "%d %d", day, hour);
+ sprintf(buf, "%02d %02d", day, hour);
break;
case DB_MINUTE:
- sprintf(buf, "%d %d%c%02d", day, hour, ts, minute);
+ sprintf(buf, "%02d %02d%c%02d", day, hour, ts, minute);
break;
case DB_SECOND:
case DB_FRACTION:
- sprintf(buf, "%d %d%c%02d%c%s%.10g",
+ sprintf(buf, "%02d %02d%c%02d%c%s%.10g",
day, hour, ts, minute, ts, xs, seconds);
break;
}
@@ -106,14 +106,14 @@
case DB_HOUR:
switch (to) {
case DB_HOUR:
- sprintf(buf, "%d", hour);
+ sprintf(buf, "%02d", hour);
break;
case DB_MINUTE:
- sprintf(buf, "%d%c%02d", hour, ts, minute);
+ sprintf(buf, "%02d%c%02d", hour, ts, minute);
break;
case DB_SECOND:
case DB_FRACTION:
- sprintf(buf, "%d%c%02d%c%s%.10g", hour, ts, minute, ts, xs,
+ sprintf(buf, "%02d%c%02d%c%s%.10g", hour, ts, minute, ts, xs,
seconds);
break;
}
@@ -121,11 +121,11 @@
case DB_MINUTE:
switch (to) {
case DB_MINUTE:
- sprintf(buf, "%d", minute);
+ sprintf(buf, "%02d", minute);
break;
case DB_SECOND:
case DB_FRACTION:
- sprintf(buf, "%d%c%s%.10g", minute, ts, xs, seconds);
+ sprintf(buf, "%02d%c%s%.10g", minute, ts, xs, seconds);
break;
}
break;
@@ -141,14 +141,14 @@
default:
switch (sqltype) {
case DB_SQL_TYPE_DATE:
- sprintf(buf, "%d%c%d%c%d", year, ds, month, ds, day);
+ sprintf(buf, "%d%c%02d%c%02d", year, ds, month, ds, day);
break;
case DB_SQL_TYPE_TIME:
- sprintf(buf, "%d%c%02d%c%s%.10g",
+ sprintf(buf, "%02d%c%02d%c%s%.10g",
hour, ts, minute, ts, xs, seconds);
break;
case DB_SQL_TYPE_TIMESTAMP:
- sprintf(buf, "%d%c%d%c%d %d%c%02d%c%s%.10g",
+ sprintf(buf, "%d%c%02d%c%02d %02d%c%02d%c%s%.10g",
year, ds, month, ds, day, hour, ts, minute, ts, xs,
seconds);
break;
More information about the grass-commit
mailing list