diff --git a/GRDB Tests/GRDBTests.swift b/GRDB Tests/GRDBTests.swift index 8693ddcd7..5272fb063 100644 --- a/GRDB Tests/GRDBTests.swift +++ b/GRDB Tests/GRDBTests.swift @@ -10,6 +10,9 @@ import XCTest import GRDB struct DatabaseDate: SQLiteValueConvertible { + + // MARK: - DatabaseDate <-> NSDate conversion + let date: NSDate // Define a failable initializer in order to consistently use nil as the @@ -22,12 +25,12 @@ struct DatabaseDate: SQLiteValueConvertible { } } - // Date -> SQLite + // MARK: - DatabaseDate <-> SQLiteValue conversion + var sqliteValue: SQLiteValue { return .Real(date.timeIntervalSince1970) } - // SQLite -> Date init?(sqliteValue: SQLiteValue) { // Don't handle the raw SQLiteValue unless you know what you do. // It is recommended to use GRDB built-in conversions instead: diff --git a/README.md b/README.md index 06e195954..622334dd1 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,9 @@ For example, let's define below the `DatabaseDate` type that stores and loads NS ```swift struct DatabaseDate: SQLiteValueConvertible { + + // MARK: - DatabaseDate <-> NSDate conversion + let date: NSDate // Define a failable initializer in order to consistently use nil as the @@ -250,12 +253,12 @@ struct DatabaseDate: SQLiteValueConvertible { } } - // Date -> SQLite + // MARK: - DatabaseDate <-> SQLiteValue conversion + var sqliteValue: SQLiteValue { return .Real(date.timeIntervalSince1970) } - // SQLite -> Date init?(sqliteValue: SQLiteValue) { // Don't handle the raw SQLiteValue unless you know what you do. // It is recommended to use GRDB built-in conversions instead: