        throw DecodingError.dataCorruptedError(in: container, debugDescription: "Date not in correct format")
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        let string = DateTime.dateEncodingFormatter.string(from: date)
        try container.encode(string)
    }

    public static func == (lhs: DateTime, rhs: DateTime) -> Bool {
        return lhs.date == rhs.date
    }

    public static func < (lhs: DateTime, rhs: DateTime) -> Bool {
        return lhs.date < rhs.date