diff --git a/MySqlPlus.Example/Program.cs b/MySqlPlus.Example/Program.cs
index 4f59874..229f343 100644
--- a/MySqlPlus.Example/Program.cs
+++ b/MySqlPlus.Example/Program.cs
@@ -20,46 +20,10 @@ namespace MontoyaTech.MySqlPlus.Example
[MySqlColumn("year")]
public uint Year = 0;
- [MySqlColumn("dateCreated", typeof(DateTime2UnixConverter))]
+ [MySqlColumn("dateCreated", typeof(DateTimeToUnixConverter))]
public DateTime DateCreated = DateTime.UtcNow;
}
- public class DateTime2UnixConverter : MySqlColumnConverter
- {
- public object ConvertFrom(object input)
- {
- if (input is ulong unix)
- {
- if (unix == 0)
- return DateTime.MinValue;
-
- return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unix).ToUniversalTime();
- }
- else
- {
- throw new NotSupportedException("Unsupported input object to convert from unix.");
- }
- }
-
- public object ConvertTo(object input)
- {
- if (input is DateTime dateTime)
- {
- if (dateTime == DateTime.MinValue)
- return 0;
-
- if (dateTime == DateTime.MaxValue)
- return ulong.MaxValue;
-
- return (ulong)(dateTime.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc))).TotalSeconds;
- }
- else
- {
- throw new NotSupportedException("Unsupported input object to convert to unix.");
- }
- }
- }
-
public static void Main(string[] args)
{
var session = new MySqlSession("");
diff --git a/MySqlPlus/DateTimeToUnixConverter.cs b/MySqlPlus/DateTimeToUnixConverter.cs
new file mode 100644
index 0000000..94c303f
--- /dev/null
+++ b/MySqlPlus/DateTimeToUnixConverter.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MontoyaTech.MySqlPlus
+{
+ ///