 
 class SQLiteDateParser {
     
-    private static let year = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let month = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let day = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let hour = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let minute = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let second = UnsafeMutablePointer<Int32>.allocate(capacity: 1)
-    private static let nanosecond = UnsafeMutablePointer<CChar>.allocate(capacity: 11)
+    private struct ParserComponents {
+        var year: Int32 = 0
+        var month: Int32 = 0
+        var day: Int32 = 0
+        var hour: Int32 = 0
+        var minute: Int32 = 0
+        var second: Int32 = 0
+        var nanosecond = ContiguousArray<CChar>.init(repeating: 0, count: 11)
+    }
 
     public static func components(from dateString: String) -> DatabaseDateComponents? {
         guard dateString.count >= 5 else { return nil }

    // - YYYY-MM-DDTHH:MM:SS
    // - YYYY-MM-DDTHH:MM:SS.SSS
    private static func datetimeComponents(from dateString: String) -> DatabaseDateComponents? {
        let parseCount = withVaList([year, month, day, hour, minute, second, nanosecond]) { pointer in
            vsscanf(dateString, "%d-%d-%d%*c%d:%d:%d.%s", pointer)
        }

        guard parseCount >= 3 else { return nil }

        var components = DateComponents()
        components.year = Int(year.pointee)
        components.month = Int(month.pointee)
        components.day = Int(day.pointee)

        guard parseCount >= 5 else { return DatabaseDateComponents(components, format: .YMD) }

        components.hour = Int(hour.pointee)
        components.minute = Int(minute.pointee)

        guard parseCount >= 6 else { return DatabaseDateComponents(components, format: .YMD_HM) }

        components.second = Int(second.pointee)

        guard parseCount >= 7 else { return DatabaseDateComponents(components, format: .YMD_HMS) }

        components.nanosecond = nanosecondsInt(for: nanosecond)

        return DatabaseDateComponents(components, format: .YMD_HMSS)
    }

    // - HH:MM:SS
    // - HH:MM:SS.SSS
    private static func timeComponents(from timeString: String) -> DatabaseDateComponents? {
        var parserComponents = ParserComponents()
        // TODO: Get rid of this pyramid when SE-0210 has shipped
        let parseCount = withUnsafeMutablePointer(to: &parserComponents.hour) { hourP in
            withUnsafeMutablePointer(to: &parserComponents.minute) { minuteP in
                withUnsafeMutablePointer(to: &parserComponents.second) { secondP in
                    parserComponents.nanosecond.withUnsafeMutableBufferPointer { nanosecondBuffer in
                        // TODO: what if vsscanf parses a string longer than nanosecond length?
                        withVaList([hourP, minuteP, secondP, nanosecondBuffer.baseAddress!]) { pointer in
                            vsscanf(timeString, "%d:%d:%d.%s", pointer)
                        }
                    }
                }
            }
        }
        
        guard parseCount >= 2 else { return nil }

        var components = DateComponents()
        components.hour = Int(parserComponents.hour)
        components.minute = Int(parserComponents.minute)

        guard parseCount >= 3 else { return DatabaseDateComponents(components, format: .HM) }

        components.second = Int(parserComponents.second)

        guard parseCount >= 4 else { return DatabaseDateComponents(components, format: .HMS) }

        components.nanosecond = nanosecondsInt(for: parserComponents.nanosecond)

        return DatabaseDateComponents(components, format: .HMSS)
    }

    private static func nanosecondsInt(for nanosecond: ContiguousArray<CChar>) -> Int {
        let nanoString = "0." + nanosecond.withUnsafeBufferPointer { String(cString: $0.baseAddress!) }
        guard let doubleValue = Double(nanoString) else { return 0 }
        return Int(doubleValue * 1_000_000_000)
    }
