Skip to content

Commit

Permalink
Corrected support for milliseconds in date/time values. #71. #76.
Browse files Browse the repository at this point in the history
SQLite supports nano-seconds, some databases only support milliseconds
and others none.
  • Loading branch information
hisystems committed Oct 5, 2012
1 parent 8d788b3 commit 172167a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion SQL/Serializers/SQLiteSerializer.cs
Expand Up @@ -7,6 +7,11 @@ namespace DatabaseObjects.SQL.Serializers
{
internal class SQLiteSerializer : Serializer
{
public SQLiteSerializer()
{
base.fractionalSecondsFormat = ".fffffff";
}

public override Database.ConnectionType Type
{
get
Expand All @@ -19,7 +24,7 @@ public override string SerializeByteArray(byte[] bytData)
{
return SerializeByteArray("X'", bytData, "'");
}

public override string SerializeAlterTableFieldsModifier(SQLTableFields.AlterModeType alterMode)
{
if (alterMode == SQLTableFields.AlterModeType.Drop)
Expand Down
4 changes: 3 additions & 1 deletion SQL/Serializers/Serializer.cs
Expand Up @@ -55,6 +55,8 @@ public override string ToString()
}
}

protected string fractionalSecondsFormat = ".fff";

/// <summary>
/// Indicates the serialization type to utilise.
/// </summary>
Expand Down Expand Up @@ -1190,7 +1192,7 @@ public virtual string SerializeDateTimeValue(DateTime dateTime)
dateTimeString += " " + dateTime.ToString("HH:mm:ss");

if (dateTime.Millisecond != 0)
dateTimeString += dateTime.ToString(".fffffff");
dateTimeString += dateTime.ToString(fractionalSecondsFormat);
}

return dateTimeString;
Expand Down

0 comments on commit 172167a

Please sign in to comment.