@@ -392,7 +392,7 @@ void QgsVectorFileWriter::init( QString vectorFileName, QString fileEncoding, co
392
392
if ( mOgrDriverName == " ESRI Shapefile" )
393
393
{
394
394
ogrType = OFTString;
395
- ogrWidth = 12 ;
395
+ ogrWidth = 12 ; // %02d:%02d:%06.3f
396
396
}
397
397
else
398
398
{
@@ -401,7 +401,15 @@ void QgsVectorFileWriter::init( QString vectorFileName, QString fileEncoding, co
401
401
break ;
402
402
403
403
case QVariant::DateTime:
404
- ogrType = OFTDateTime;
404
+ if ( mOgrDriverName == " ESRI Shapefile" )
405
+ {
406
+ ogrType = OFTString;
407
+ ogrWidth = 24 ; // "%04d/%02d/%02d %02d:%02d:%06.3f"
408
+ }
409
+ else
410
+ {
411
+ ogrType = OFTDateTime;
412
+ }
405
413
break ;
406
414
407
415
default :
@@ -1794,14 +1802,21 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
1794
1802
0 , 0 , 0 , 0 );
1795
1803
break ;
1796
1804
case QVariant::DateTime:
1797
- OGR_F_SetFieldDateTime ( poFeature, ogrField,
1798
- attrValue.toDateTime ().date ().year (),
1799
- attrValue.toDateTime ().date ().month (),
1800
- attrValue.toDateTime ().date ().day (),
1801
- attrValue.toDateTime ().time ().hour (),
1802
- attrValue.toDateTime ().time ().minute (),
1803
- attrValue.toDateTime ().time ().second (),
1804
- 0 );
1805
+ if ( mOgrDriverName == " ESRI Shapefile" )
1806
+ {
1807
+ OGR_F_SetFieldString ( poFeature, ogrField, mCodec ->fromUnicode ( attrValue.toDateTime ().toString ( " yyyy/MM/dd hh:mm:ss.zzz" ) ).data () );
1808
+ }
1809
+ else
1810
+ {
1811
+ OGR_F_SetFieldDateTime ( poFeature, ogrField,
1812
+ attrValue.toDateTime ().date ().year (),
1813
+ attrValue.toDateTime ().date ().month (),
1814
+ attrValue.toDateTime ().date ().day (),
1815
+ attrValue.toDateTime ().time ().hour (),
1816
+ attrValue.toDateTime ().time ().minute (),
1817
+ attrValue.toDateTime ().time ().second (),
1818
+ 0 );
1819
+ }
1805
1820
break ;
1806
1821
case QVariant::Time:
1807
1822
if ( mOgrDriverName == " ESRI Shapefile" )
0 commit comments